16,748
社区成员
发帖
与我相关
我的任务
分享
'取得识别结果
Private Declare Function GetRecogResult Lib "IDCard.dll" (ByVal nIndex As Integer, ByRef lpBuffer As Byte, ByRef nBufferLen As Integer) As Integer
'获取识别结果
Dim MAX_CH_NUM As Integer = 128
Dim szFieldValue As String
Dim szFieldName As String
Dim a As Byte()
Dim b As Byte()
szFieldName = New String(CChar(""), 128)
szFieldValue = New String(CChar(""), 128)
Dim nIndex As Integer = 1
ResultTextBox.Text = "识别成功" & vbCrLf
Do While (1)
Dim strTmp As String
Dim strTmp1 As String
b = System.Text.Encoding.Unicode.GetBytes(szFieldValue)
'获取nIndex对应的识别内容
nRet = GetRecogResult(nIndex, b(0), MAX_CH_NUM)
strTmp = System.Text.Encoding.Unicode.GetString(b) & vbCrLf
If nRet = 3 Then
Exit Sub
End If
'获取识别的字段名称,nIndex对应的字段名称可以查开发文档
Dim nnRet As Integer
a = System.Text.Encoding.Unicode.GetBytes(szFieldName)
nnRet = GetFieldName(nIndex, a(0), MAX_CH_NUM)
strTmp1 = System.Text.Encoding.Unicode.GetString(a) & ":"
'用于显示
If nnRet = 0 Then
ResultTextBox.Text += strTmp1
ResultTextBox.Text += ":"
ResultTextBox.Text += strTmp
ResultTextBox.Text += vbCrLf
End If
nIndex += 1
Loop
function GetRecogResult(nIndex: integer; var lpBuffer: Byte;var nBufferLen: integer);stdcall;external 'IDCard';