Public Class Form1
Dim idx As Integer = -1
<System.Runtime.InteropServices.DllImport("www.zfuwen.com.KeyCodeDll.dll", EntryPoint:="www_zfuwen_com_QQ_251578917_InitKeyCode")> Private Shared Function InitKeyCode(ByVal idx As Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("www.zfuwen.com.KeyCodeDll.dll", EntryPoint:="www_zfuwen_com_QQ_251578917_FreeKeyCode")> Private Shared Function FreeKeyCode(ByVal idx As Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("www.zfuwen.com.KeyCodeDll.dll", EntryPoint:="www_zfuwen_com_QQ_251578917_GetCodeResult")> Private Shared Function GetCodeResult(ByVal strFileName As String, ByVal strOutCode As System.Text.StringBuilder, ByVal Idx As Integer) As Integer
End Function
Private Sub Btest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btest.Click
If (idx < 0) Then
idx = InitKeyCode(0)
If (idx < 0) Then
MessageBox.Show("初始化失败")
Return
End If
End If
Dim res As System.Text.StringBuilder = New System.Text.StringBuilder()
Dim startTick As System.DateTime = System.DateTime.Now
Dim retcount As Integer
retcount = GetCodeResult(Tinputfile.Text, res, idx)
Dim endTick As System.DateTime = System.DateTime.Now
If (retcount > 0) Then
Treg.Text = "识别结果:" + res.ToString() + ",时间:" + ((endTick.Ticks - startTick.Ticks) / System.TimeSpan.TicksPerMillisecond).ToString() + ",当前时间:" + endTick.ToString("yyyy-MM-dd HH:mm:ss")
Else
Treg.Text = "识别失败"
End If
End Sub
Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
If (idx >= 0) Then
FreeKeyCode(idx)
idx = -1
End If
End Sub
End Class