紧急求助神思二代身份证读卡器调用问题
机型:神思SS628型usb接口二代身份证
巡检代码如下:
Private Sub Timer1_Timer()
Dim cmd As Byte
Dim para0 As Long
Dim para1 As Long
Dim para2 As Long
Dim FileName As String
Dim FileNumber As Integer
Dim FileLength As Long
Dim sData As String
Dim sName As String
Dim byData(256) As Byte
Dim sSex As String
Dim sFolk As String
Dim sBirth As String
Dim sAddr As String
Dim sID As String
Dim sIssue As String
Dim sBegin As String
Dim sEnd As String '
If Not bRun Then
bRun = True
'========================================================
txtMsg.Caption = "请放卡..."
cmd = 67 '0x43
para0 = 0
para1 = 8811
para2 = 9986
nRet = UCommand1(cmd, para0, para1, para2) '验证卡
If nRet = 62171 Then
txtMsg.Caption = "正在读卡..."
'--------------------------------------------
sLname.Caption = ""
sLsex.Caption = ""
sLfolk.Caption = ""
sLbirth.Caption = ""
sLAddr.Caption = ""
sLissue.Caption = ""
sLID.Caption = ""
sLindate.Caption = ""
sLnewaddr.Caption = ""
Picture1.Picture = LoadPicture(App.Path & "\blank.bmp")
'--------------------------------------------
cmd = 68 '0x44 读卡内信息
para0 = 0
para1 = 8811
para2 = 9986
nRet = UCommand1(cmd, para0, para1, para2) '读卡内信息
If nRet = 62171 Then
'On Error GoTo FileContainsError
FileName = App.Path & "\wz.txt" ' "E:\VB\wz.txt" '调试时指定路径,因为VB调试是工作路径不是程序路径
FileNumber = FreeFile
Open FileName For Binary Access Read Shared As FileNumber
FileLength = LOF(FileNumber)
If FileLength = 256 Then
Get FileNumber, 1, byData
sData = byData
'姓名
sName = Mid$(sData, 1, 15)
Trim (sName)
sLname.Caption = sName
'MsgBox sName, vbOKOnly, "Info", 0, 0
'性别
sSex = Mid$(sData, 16, 1)
Trim (sSex)
If sSex = "1" Then
sLsex.Caption = "男"
ElseIf sSex = "2" Then
sLsex.Caption = "女"
Else
sLsex.Caption = "非法"
End If
'MsgBox sSex, vbOKOnly, "Info", 0, 0
'民族
sFolk = Mid$(sData, 17, 2)
Trim (sFolk)
sLfolk.Caption = GetFolk(sFolk)
'MsgBox sFolk, vbOKOnly, "Info", 0, 0
'出生日期
sBirth = Mid$(sData, 19, 8)
Trim (sBirth)
sLbirth.Caption = Mid$(sBirth, 1, 4) + "年" + Mid$(sBirth, 5, 2) + "月" + Mid$(sBirth, 7, 2) + "日"
'MsgBox sBirth, vbOKOnly, "Info", 0, 0
'地址
sAddr = Mid$(sData, 27, 35)
Trim (sAddr)
sLAddr.Caption = sAddr
'MsgBox sAddr, vbOKOnly, "Info", 0, 0
'身份证号
sID = Mid$(sData, 62, 18)
Trim (sID)
sLID.Caption = sID
'MsgBox sID, vbOKOnly, "Info", 0, 0
'签发机关
sIssue = Mid$(sData, 80, 15)
Trim (sIssue)
sLissue.Caption = sIssue
'MsgBox sIssue, vbOKOnly, "Info", 0, 0
'有效期限
sBegin = Mid$(sData, 95, 8)
Trim (sBegin)
'MsgBox sBegin, vbOKOnly, "Info", 0, 0
sEnd = Mid$(sData, 103, 8)
Trim (sEnd)
'MsgBox sEnd, vbOKOnly, "Info", 0, 0
sLindate.Caption = sBegin + "-" + sEnd
Picture1.Picture = LoadPicture(App.Path & "\zp.bmp")
End If
Close FileNumber
ElseIf nRet = -5 Then
MsgBox "软件未授权!", vbOKOnly, "提示信息", 0, 0
End If
End If
'========================================================
bRun = False
End If
End Sub