2,722
社区成员
发帖
与我相关
我的任务
分享
首先要搞清你的 IC卡读写卡器 是真正的USB,还是 USB转串口,如果后者
Declare Integer rf_init In MWRF32.Dll Integer port,Long baud && 声明。注意 MWRF32.DLL 的路径,必要是加上路径或COPY至SYSTEM32目录
lnHandle=rf_init(3,9600) && 初始化串口3,波特率为9600
If lnHandle<=0
Messagebox('初始化串口失败!',48,'信息提示')
Return
Endif
* 如果 lnHandle>0,说明初始化成功,lnHandle为接口打开此串口返回的句柄,此句柄为后面对串口读写时要用到。
* 一般 USB转串口 是需要驱动的,看你的情况是真正的USB,这个接口函数是串口,明显不对应,向厂家要USB接口,不用要VFP例程,一般都有VB例程,有VB的,VFP就可以参考用。
关于句柄的理解,你可以参考下面例子:
Local gnFileHandle,nSize,cString
gnFileHandle = Fopen("test.txt") && gnFileHandle 为 Fopen 函数打开的文件句柄,此句柄后面读写要用到。
* Seek to end of file to determine number of bytes in the file.
nSize = Fseek(gnFileHandle, 0, 2) && 移动指针到末尾
If nSize <= 0
* If file is empty, display an error message.
Wait Window "This file is empty!" Nowait
Else
* If file is not empty, store the file's contents in memory
* and display the text in the main Visual FoxPro window.
= Fseek(gnFileHandle, 0, 0) && 移动指针到开始
cString = Fread(gnFileHandle, nSize)
? cString
Endif
= Fclose(gnFileHandle) && 关闭文件