怎样通过身份证识别仪用vfp读取信息存入表中
各位高手,本人刚开始结束vf,最近买了台身份证识别仪,想通过识别仪把读取的数据存到.dbf表中,请问可以实现么?刚找了一个前人编写的程序自己修改了下,但是还是有问题,请教高手指点。
DECLARE Integer Syn_StartFindIDCard IN SynIDCardAPI.dll iPort, String @pucManaInfo, Integer iIfOpen
DECLARE Integer Syn_SelectIDCard IN SynIDCardAPI.dll iPort, String @pucManaMsg, Integer iIfOpen
DECLARE Integer Syn_ReadBaseMsg IN SynIDCardAPI.dll iPort, String @pucCHMsg, Integer @puiCHMsgLen, ;
String @pucPHMsg, Integer @puiPHMsgLen, Integer iIfOpen
LOCAL iRet As Integer && 返回码
LOCAL iPort As Integer && 端口号
LOCAL iIfOpen As Integer && 是否需要打开端口
LOCAL find_sta
find_sta=.t.
LOCAL pucManaInfo As String
LOCAL pucManaMsg As String
LOCAL pucCHMsg As String && 文字信息
LOCAL pucPHMsg As String && 照片信息
LOCAL pucFPMsg As String && 指纹信息
LOCAL uiCHMsgLen As Integer, uiPHMsgLen As Integer
iRet = 0
pucManaInfo = SPACE(4)
pucManaMsg = SPACE(8)
pucCHMsg = SPACE(512)
pucPHMsg = SPACE(1024)
pucFPMsg = SPACE(1024)
uiCHMsgLen = 0
uiPHMsgLen = 0
iPort =1001 && 端口在系统设置下设置 1001为USB 设备
iIfOpen = 0
IF iIfOpen = 0
iRet = Syn_OpenPort(iPort)
IF iRet != 0x90
MESSAGEBOX("Syn_OpenPort 错误, 错误代码为 " + LTRIM(STR(iRet)), 16, '错误')
Syn_ClosePort(iPort)
RETURN
ENDIF
ENDIF
thisform.conTAINER2.Visible =.t.
DO WHILE .T. && 找卡
iRet = Syn_StartFindIDCard(iPort, @pucManaInfo, iIfOpen)
IF iRet = 0x9f
iRet = Syn_SelectIDCard(iPort, @pucManaMsg, iIfOpen)
IF iRet == 0x90
EXIT
ENDIF
ENDIF
IF MESSAGEBOX("没有找到身份证,请放身份证?", 32 + 4, '询问') <> 6
thisform.conTAINER21.Visible =.f.
find_sta=.f.
EXIT
ENDIF
*WAIT WINDOW \"请放身份证...,退出请按C键。\" TIMEOUT 2 TO zcs
*IF zcs=\"c\"
* find_sta=.f.
* tthisform.conTAINER2.Visible =.f.
* EXIT
*ENDIF
ENDDO
iRet = Syn_ReadBaseMsg(iPort, @pucCHMsg, @uiCHMsgLen, @pucPHMsg, @uiPHMsgLen, iIfOpen)
IF iRet != 0x90
MESSAGEBOX("Syn_ReadBaseMsg 错误, 错误代码为 " + LTRIM(STR(iRet)), 16, '错误')
IF iIfOpen = 0
Syn_ClosePort(iPort)
find_sta=.f.
RETURN
ENDIF
ENDIF
WAIT WINDOW "身份证信息获取成功!" NOWAIT
tmp_read=STRCONV(left(pucCHMsg,uiCHMsgLen),6)
xm_read=ALLTRIM(LEFTC(tmp_read,15))&&读出的字符串前15位是姓名
xbpd=SUBSTRC(tmp_read,16,1)&&读出的字符串前16位是性别,1代表男,2代表女
mzpd=SUBSTRC(tmp_read,17,2)&&读出的字符串前17-18位是民族,01是汉族
tmp_rq=SUBSTRC(tmp_read,19,8)&&读出的字符串前19-25位是出生日期
IF xbpd="1"
xb_read="男"
ELSE
xb_read="女"
ENDIF
DO CASE
CASE mzpd="01"
mz_read="汉"
ENDCASE
SET DATE TO mdy
csrq_read=CTOD(SUBSTR(tmp_rq,5,2)+"/"+SUBSTR(tmp_rq,7,2)+"/"+LEFT(tmp_rq,4))
dz_read=SUBSTRC(tmp_read,27,35)&&地址的数据
sfzhm_read=SUBSTRC(tmp_read,62,18)&&身份证号码的数据
qfjg_read=ALLTRIM(SUBSTRC(tmp_read,80,15))&&签发机关的数据
tmp_rqq=SUBSTRC(tmp_read,95,8)&&签发日期
tmp_rqz=SUBSTRC(tmp_read,103,8)&&有限期限
yxqq_read=CTOD(SUBSTR(tmp_rqq,5,2)+"/"+SUBSTR(tmp_rqq,7,2)+"/"+LEFT(tmp_rqq,4))
yxqz_read=CTOD(SUBSTR(tmp_rqz,5,2)+"/"+SUBSTR(tmp_rqz,7,2)+"/"+LEFT(tmp_rqz,4))
qtxx_read=RIGHTC(tmp_read,18)&&其他内容,暂时不知道是什么
photo_tmp=SYS(5)+SYS(2003)+"\\"+ALLTRIM(xm_read)+".wlt" &&这里是获得照片的程序
=STRTOFILE(LEFT(pucPHMsg,uiPHMsgLen),photo_tmp,1)
IF iIfOpen = 0 &&关闭端口
Syn_ClosePort(iPort)
RETURN
ENDIF