16,554
社区成员
发帖
与我相关
我的任务
分享
Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As IntPtr
Public Declare Function GetProcAddress Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As Integer, ByVal lpProcName As String) As IntPtr
Public Delegate Sub VoidDelegate()
Public Delegate Sub GetVerifyCodeDelegate(ByVal r As Byte(), ByVal p As Char())
Private Sub TestExternLibrary()
Dim hDll As IntPtr = LoadLibrary("VerifyCode.dll")
Dim hProc As IntPtr = GetProcAddress(hDll, "InitVerifyCodePick")
Dim InitVerifyCodePick As VoidDelegate = Marshal.GetDelegateForFunctionPointer(hProc, GetType(VoidDelegate))
hProc = GetProcAddress(hDll, "UnInitVerifyCodePick")
Dim UnInitVerifyCodePick As VoidDelegate = Marshal.GetDelegateForFunctionPointer(hProc, GetType(VoidDelegate))
hProc = GetProcAddress(hDll, "GetVerifyCode")
Dim GetVerifyCode As GetVerifyCodeDelegate = Marshal.GetDelegateForFunctionPointer(hProc, GetType(GetVerifyCodeDelegate))
InitVerifyCodePick()
Dim r(0 To 15) As Byte
Dim p As Char() = "c:\\1.jpg".ToCharArray()
GetVerifyCode(r, p)
UnInitVerifyCodePick()
End Sub