VB 动态调用未注册DLL 2/14
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long
Private Sub Command1_Click()
On Error Resume Next
Dim lb As Long, pa As Long
'以 text.dll 为例,设 text.dll 功能跟 user32.dll 完全相同。
lb = LoadLibrary(App.Path & "\text.dll")
'取得 text.dll 中 SetWindowTextA 函数的地址
pa = GetProcAddress(lb, "ExploreMap")
'调用 SetWindowTextA 函数过程
pa = CallWindowProc(pa, ByVal 0&, ByVal 0&, ByVal 0&, ByVal 0&)
'释放...
FreeLibrary lb
Me.Caption = pa
End Sub
目前有0条回应
Comment
Trackback