FT的第三方硬件調用例子真的非常少,發一個神思二代身份證讀卡機調用例子吧,指紋考勤機,身份證,門襟這些常用的配套硬件真希望能有些例子可以參考。
====全局代碼====
Public Declare Function UCommand1 Lib "RdCard.dll" (ByRef pCmd As Byte, ByRef para0 As Integer, ByRef para1 As Integer, ByRef para2 As Integer) As Integer
=====窗口AfterLoad====
Dim cmd As Byte
Dim nRet,para0,para1,para1 As Integer
cmd = 65 '0x41初始化端口
para0 = 0
para1 = 8811
para2 = 9986
nRet = UCommand1(cmd, para0, para1, para2)
If nRet = 62171 Then
e.Form.TimerEnabled = True
e.Form.Controls("Label10").Text = "連接機具成功"
Else
e.Form.TimerEnabled = False
e.Form.Controls("Label10").Text = nRet + "連接機具失敗"
End If
=====窗口TimerTick====
Dim cmd As Byte
Dim nRet,para0,para1,para2 As Integer
Dim bRun As Boolean
If Not bRun Then
bRun = True
e.Form.Controls("Label10").Text = "請放卡..."
cmd = 67 '0x43驗證卡
para0 = 0
para1 = 8811
para2 = 9986
nRet = UCommand1(cmd, para0, para1, para2) '驗證卡
If nRet = 62171 Then
e.Form.Controls("Label10").Text = "正在讀卡..."
cmd = 68 '0x44 讀卡內信息
para0 = 0
para1 = 8811
para2 = 9986
nRet = UCommand1(cmd, para0, para1, para2) '讀卡內信息
If nRet = 62171 Then
Functions.Execute("Parse")
ElseIf nRet = -5 Then
MessageBox.Show("軟件未授權","提示")
End If
End If
bRun = False
End If
=====窗口AfterClose====
UCommand1(66, 0, 0, 0) '關閉端口
======函數Parse======
Dim Info As String
Info = FileSys.ReadAllText(ApplicationPath & "wx.txt", Encoding.Default) '读取生成的文本文件
info = info.Replace(vbcrlf,vblf) '将回车换行替换为换行
Dim pars() As String = Info.Split(vblf) '将读取的信息拆分为数组
Dim r As Row = Tables("人事檔案").Current
r("姓名") = pars(0).Trim()
r("性別") = pars(1).Trim()
r("民族") = pars(2).Trim()
r("出生日期") = pars(3).replace("年","-").Replace("月","-").Replace("日","")
r("戶籍地址") = pars(4)
r("身份證") = pars(5)
r("簽發機關") = pars(6)
r("簽發日期") = pars(7)
r("有效截止日期") = pars(8)
FileSys.CopyFile(ApplicationPath & "zp.bmp", ProjectPath & "\Attachments\" & r("身份證") & ".bmp",True) '照片复制到Attachments目录
r("照片") = r("身份證") & ".bmp"
此為自動讀卡,手動讀卡可參照狐爸的幫助例子添加,如出現未授權提示請記下身份證閱讀機背面的序號向神思官方要授權文件。
附上神思SDK
[此贴子已经被作者于2014-5-2 19:10:11编辑过]