|
|

楼主 |
发表于 2007-4-28 17:39:00
|
显示全部楼层
Re:如何动态的引用Win32 API??
找到了!!
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 FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal Hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Command1_Click()
Dim DllHand As Long
Dim DllProc As Long
DllHand = LoadLibrary("你的DLL路径")
If DllHAND = 0 Then msgbox "没法加载DLL"
DllProc = GetProcAddress(DllHand, "你的DLL函数名")
if dllproc=0 then msgbox "没找到此函数"
CallWindowProc DllProc, DllHand, 0, 0, 0
执行你的DLL的函数
FreeLibrary DllHand '释放DLL
End sub
|
|