二代身份证读卡器二次开发代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
DoEvents Loop Inet1.Execute , "QUIT" End Function
Public Function ostudent() Dim CardPUCIIN Dim ll, i, aa, bb Open asx & "c:\aha.bmp" For Output As #1 Close #1 CardPUCIIN = Space(4) ll = SDT_StartFindIDCard(1001, CardPUCIIN, 1) If ll <> 128 And ll <> 1 Then
<td width="175" class="color2" > <P align=left> <input size=25 name=fname maxLength=25 >
</P></td> </tr> <tr>
<td class="color2" > <P align=center><FONT size=3>性别:</FONT></P></td> <td class="color2" > <P align=left>
务
end if
end function
</script>
<script language="JavaScript"> function res(){ var i = Math.random();
document.getElementById("photoid").src="c:/aha.bmp";} //显示读出的身份证照片 </script>
Dim CardPUCSN Dim mf(512) As Byte Dim pf(1024) As Byte Dim ml As Long Dim pl As Long Dim ld CardPUCSN = Space(8) ml = 512 pl = 1024 ld = SDT_SelectIDCard(1001, CardPUCSN, 1) Call SDT_ReadBaseMsg(1001, mf(0), ml, pf(0), pl, 1) i=1 While i < 513
aa = CLng(mf(i)) * 256 + CLng(mf(i - 1)) i=i+2 bb = bb + ChrW(aa) Wend 'mf = StrConv(mf, 128) '把 Unicode 码转换成 ansi 码 ostudent = bb
'下面提取照片 Open asx & "c:\aha.wlt" For Output As #1 Close #1 Open "c:\Aha.wlt" For Binary As #1 i=0 While i < 1024
Put #1, , pf(i) i=i+1 Wend Close #1 Call GetBmp("c:\aha.wlt", 2) ‘调用读卡器函数库 Else MsgBox ("请重放身份证") ostudent = "1" End If End Function
文件 htmok,生成 htmok.ocx 后打包成 htmok.cab(如何打包上百度找,vb 有)。
没有返回值。 2.代码 Private Declare Function GetBmp Lib "c:\windows\system32\WltRS.dll" (ByVal photo As String, ByVal xk As Integer) As Long Private Declare Function SDT_OpenPort Lib "c:\windows\system32\sdtapi.dll" (ByVal usbport As Long) As Long Private Declare Function SDT_ClosePort Lib "c:\windows\system32\sdtapi.dll" (ByVal usbport1 As Long) As Long Private Declare Function SDT_StartFindIDCard Lib "c:\windows\system32\sdtapi.dll" (ByVal X1 As Long, ByVal mf1 As String, ByVal Y1 As Long) As Long Private Declare Function SDT_SelectIDCard Lib "c:\windows\system32\sdtapi.dll" (ByVal X2 As Long, ByVal mf2 As String, ByVal Y2 As Long) As Long Private Declare Function SDT_ReadBaseMsg Lib "c:\windows\system32\sdtapi.dll" (ByVal X As Integer, ByRef mf As Byte, ByRef ml As Long, ByRef pf As Byte, ByRef pl As Long, ByVal Y As Integer) As Integer
<input size=25 name=fadd maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>证号:</FONT></P></td> <td class="color2" > <P align=left>
Public Function FTPTxtFile(site, file) 'ftp 上传 Inet1.URL = "ftp://" & site Inet1.Protocol = icFTP Inet1.UserName = "upphoto" ‘ftp 用户(可改) Inet1.Password = "upphoto" ‘ftp 密码(可改) Inet1.Execute , "PUT c:/aha.bmp " & file ‘上传 c 盘根目录的 aha.bmp 文件 Do While Inet1.StillExecuting
<input size=25 name=fid maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>发证机关:</FONT></P></td> <td class="color2" > <P align=left>
<input size=25 name=fsex maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>民族:</FONT></P></td> <td class="color2" > <P align=left>
<input size=25 name=fbirth maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>住址:</FONT></P></td> <td class="color2" > <P align=left>
3.测试代码(保存为 test.htm 就可以了) 测试时会提示安装 cab 包(把 cab 包与 test.htm 放在同一个文件夹内)。 <HTML> <HEAD> <TITLE>htmok.CAB</TITLE> </HEAD> <BODY> <!--网页调用--> <!-调用插件--> <OBJECT
if len(Trim(mf))>1 then '是否读出数据
readname = 1
i=1
d=1
While readname < Len(mf) '把读出的数据拆分
If Mid(mf, readname, 1) = " " Then
ii(i) = Mid(mf, d, readname - d)
二代身份证读卡器二次开发代码(通用)
本开发代码用 vb 编写经测试可以兼容现有的大部份二代身份证读卡器,使用本控件前请先安装二代身份证读卡器的驱程, 本控件用于网页开发。
1.说明与准备 进入 vb 新建工程 activex 控件,需要下图部件,这个是 ftp 部件。
做法右击左面工具 选部件就可以出现上图。 本控件只提供两个对外函数接口 (1)hx_IDname( ) 读身份证主函数接口没有参数,有返回值。 (2)toftp(urln, file) 上传照片到 ftp 服务器,照片以身份证号保存,参数 1 服器的 url,参数 2 上传后的文件名称。
stuname = ii(1)
'姓名
addres = Mid(ii(2), 12) '住址
birthday = Mid(idno1, 7, 4) + "-" + Mid(idno1, 11, 2) + "-" + Mid(idno1, 13, 2) '出生日期
If Int(CInt(sex1) / 2) = CInt(sex1) / 2 Then '性别转换
sex1 = "女"
Else
sex1 = "男"
End If
fname.value = stuname
fsex.value = sex1
fbirth.value = birthday
fadd.value = addres
fid.value = idno1
fdep.value=pf
pf=icread.toftp("192.168.2.218",idno1&".bmp") 'ip 为存放身份证照片的服务器 IP 地址,此地址要建 ftp 服
Public Function hx_IDname() As String '供外部调用函数 hx_IDname = ostudent() End Function
Public Function toftp(urln, file) '供外部调用函数 Call FTPTxtFile(urln, file) End Function
While Mid(mf, readname, 1) = " "
readname = readname + 1
Wend
d = readname
i=i+1
End If
readname = readname + 1
Wend
源自文库
idno1 = Mid(ii(3), 1, 18) '身份证号
sex1 = Mid(idno1, 17, 1) '性别代码
</OBJECT> <script language=vbscript>
function IC_read() Dim readname, i, d, idno1, sex1, stuname, addres, idno, birthday,mf,pf Dim ii(10) mf=icread.hx_IDname() '通过插内函数读出身份证数据 'msgbox(mf) '显示读出的原内容 内里有民族,身份证有效期等
<input size=25 name=fnation maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>出生:</FONT></P></td> <td class="color2" > <P align=left>
CLASSID="CLSID:900623A9-FF0F-4BAD-9CB7-EE10C761267E" CODEBASE="htmok.CAB#version=1,0,0,0" width=0 height=0 align=center hspace=0 vspace=0
ID="icread" >
<table width="471" border="1" cellspacing="0" cellpadding="0" > <tr> <td width="114" class="color2" > <P align=center><FONT size=3>姓名:</FONT></P></td> <td width="174" rowspan="8" class="color2" > <IMG id ="photoid" ></td>
Public Function ostudent() Dim CardPUCIIN Dim ll, i, aa, bb Open asx & "c:\aha.bmp" For Output As #1 Close #1 CardPUCIIN = Space(4) ll = SDT_StartFindIDCard(1001, CardPUCIIN, 1) If ll <> 128 And ll <> 1 Then
<td width="175" class="color2" > <P align=left> <input size=25 name=fname maxLength=25 >
</P></td> </tr> <tr>
<td class="color2" > <P align=center><FONT size=3>性别:</FONT></P></td> <td class="color2" > <P align=left>
务
end if
end function
</script>
<script language="JavaScript"> function res(){ var i = Math.random();
document.getElementById("photoid").src="c:/aha.bmp";} //显示读出的身份证照片 </script>
Dim CardPUCSN Dim mf(512) As Byte Dim pf(1024) As Byte Dim ml As Long Dim pl As Long Dim ld CardPUCSN = Space(8) ml = 512 pl = 1024 ld = SDT_SelectIDCard(1001, CardPUCSN, 1) Call SDT_ReadBaseMsg(1001, mf(0), ml, pf(0), pl, 1) i=1 While i < 513
aa = CLng(mf(i)) * 256 + CLng(mf(i - 1)) i=i+2 bb = bb + ChrW(aa) Wend 'mf = StrConv(mf, 128) '把 Unicode 码转换成 ansi 码 ostudent = bb
'下面提取照片 Open asx & "c:\aha.wlt" For Output As #1 Close #1 Open "c:\Aha.wlt" For Binary As #1 i=0 While i < 1024
Put #1, , pf(i) i=i+1 Wend Close #1 Call GetBmp("c:\aha.wlt", 2) ‘调用读卡器函数库 Else MsgBox ("请重放身份证") ostudent = "1" End If End Function
文件 htmok,生成 htmok.ocx 后打包成 htmok.cab(如何打包上百度找,vb 有)。
没有返回值。 2.代码 Private Declare Function GetBmp Lib "c:\windows\system32\WltRS.dll" (ByVal photo As String, ByVal xk As Integer) As Long Private Declare Function SDT_OpenPort Lib "c:\windows\system32\sdtapi.dll" (ByVal usbport As Long) As Long Private Declare Function SDT_ClosePort Lib "c:\windows\system32\sdtapi.dll" (ByVal usbport1 As Long) As Long Private Declare Function SDT_StartFindIDCard Lib "c:\windows\system32\sdtapi.dll" (ByVal X1 As Long, ByVal mf1 As String, ByVal Y1 As Long) As Long Private Declare Function SDT_SelectIDCard Lib "c:\windows\system32\sdtapi.dll" (ByVal X2 As Long, ByVal mf2 As String, ByVal Y2 As Long) As Long Private Declare Function SDT_ReadBaseMsg Lib "c:\windows\system32\sdtapi.dll" (ByVal X As Integer, ByRef mf As Byte, ByRef ml As Long, ByRef pf As Byte, ByRef pl As Long, ByVal Y As Integer) As Integer
<input size=25 name=fadd maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>证号:</FONT></P></td> <td class="color2" > <P align=left>
Public Function FTPTxtFile(site, file) 'ftp 上传 Inet1.URL = "ftp://" & site Inet1.Protocol = icFTP Inet1.UserName = "upphoto" ‘ftp 用户(可改) Inet1.Password = "upphoto" ‘ftp 密码(可改) Inet1.Execute , "PUT c:/aha.bmp " & file ‘上传 c 盘根目录的 aha.bmp 文件 Do While Inet1.StillExecuting
<input size=25 name=fid maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>发证机关:</FONT></P></td> <td class="color2" > <P align=left>
<input size=25 name=fsex maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>民族:</FONT></P></td> <td class="color2" > <P align=left>
<input size=25 name=fbirth maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>住址:</FONT></P></td> <td class="color2" > <P align=left>
3.测试代码(保存为 test.htm 就可以了) 测试时会提示安装 cab 包(把 cab 包与 test.htm 放在同一个文件夹内)。 <HTML> <HEAD> <TITLE>htmok.CAB</TITLE> </HEAD> <BODY> <!--网页调用--> <!-调用插件--> <OBJECT
if len(Trim(mf))>1 then '是否读出数据
readname = 1
i=1
d=1
While readname < Len(mf) '把读出的数据拆分
If Mid(mf, readname, 1) = " " Then
ii(i) = Mid(mf, d, readname - d)
二代身份证读卡器二次开发代码(通用)
本开发代码用 vb 编写经测试可以兼容现有的大部份二代身份证读卡器,使用本控件前请先安装二代身份证读卡器的驱程, 本控件用于网页开发。
1.说明与准备 进入 vb 新建工程 activex 控件,需要下图部件,这个是 ftp 部件。
做法右击左面工具 选部件就可以出现上图。 本控件只提供两个对外函数接口 (1)hx_IDname( ) 读身份证主函数接口没有参数,有返回值。 (2)toftp(urln, file) 上传照片到 ftp 服务器,照片以身份证号保存,参数 1 服器的 url,参数 2 上传后的文件名称。
stuname = ii(1)
'姓名
addres = Mid(ii(2), 12) '住址
birthday = Mid(idno1, 7, 4) + "-" + Mid(idno1, 11, 2) + "-" + Mid(idno1, 13, 2) '出生日期
If Int(CInt(sex1) / 2) = CInt(sex1) / 2 Then '性别转换
sex1 = "女"
Else
sex1 = "男"
End If
fname.value = stuname
fsex.value = sex1
fbirth.value = birthday
fadd.value = addres
fid.value = idno1
fdep.value=pf
pf=icread.toftp("192.168.2.218",idno1&".bmp") 'ip 为存放身份证照片的服务器 IP 地址,此地址要建 ftp 服
Public Function hx_IDname() As String '供外部调用函数 hx_IDname = ostudent() End Function
Public Function toftp(urln, file) '供外部调用函数 Call FTPTxtFile(urln, file) End Function
While Mid(mf, readname, 1) = " "
readname = readname + 1
Wend
d = readname
i=i+1
End If
readname = readname + 1
Wend
源自文库
idno1 = Mid(ii(3), 1, 18) '身份证号
sex1 = Mid(idno1, 17, 1) '性别代码
</OBJECT> <script language=vbscript>
function IC_read() Dim readname, i, d, idno1, sex1, stuname, addres, idno, birthday,mf,pf Dim ii(10) mf=icread.hx_IDname() '通过插内函数读出身份证数据 'msgbox(mf) '显示读出的原内容 内里有民族,身份证有效期等
<input size=25 name=fnation maxLength=25 > </P></td> </tr> <tr> <td class="color2" > <P align=center><FONT size=3>出生:</FONT></P></td> <td class="color2" > <P align=left>
CLASSID="CLSID:900623A9-FF0F-4BAD-9CB7-EE10C761267E" CODEBASE="htmok.CAB#version=1,0,0,0" width=0 height=0 align=center hspace=0 vspace=0
ID="icread" >
<table width="471" border="1" cellspacing="0" cellpadding="0" > <tr> <td width="114" class="color2" > <P align=center><FONT size=3>姓名:</FONT></P></td> <td width="174" rowspan="8" class="color2" > <IMG id ="photoid" ></td>