01-01-2005, 09:11 AM
Hi, I'm trying to make a small function that allows you to call DLL's from the LoadLibrary and GetProcAddress functions. However the following code doesn't compile.
The problem is in the lines with dllhand = LoadLibrary(dllname) and
tempfunc = GetProcAddress(dllhand, dllfunc).
The following which does compile does not work either:
MsgBox = GetProcAddress(LoadLibrary("c:\windows\system32\user32.dll"), "MessageBoxA")
Help?
Thanks,
Kris
Code:
'$Include: 'win\kernel32.bi'
Declare Function DLLFunc(dllname As String, dllfunc As String) As Integer
Dim MsgBox As Function (hwnd As Integer, lptext As String, lpcap As String, msgtype As Integer) As Integer
Function DLLFunc(dllname As String, dllfunc As String) As Integer
Dim dllhand As Integer, tempfunc As Integer
dllhand = LoadLibrary(dllname)
If dllhand Then
tempfunc = GetProcAddress(dllhand, dllfunc)
If tempfunc Then
DLLFunc = tempfunc
Else
DLLFunc = 0
End If
Else
DLLFunc = 0
End If
End Function
MsgBox = DLLFunc("user32.dll","MessageBoxA")
Print MsgBox(0,"Test", "Test",0)
Do Until Inkey$ <> ""
Loop
The problem is in the lines with dllhand = LoadLibrary(dllname) and
tempfunc = GetProcAddress(dllhand, dllfunc).
The following which does compile does not work either:
MsgBox = GetProcAddress(LoadLibrary("c:\windows\system32\user32.dll"), "MessageBoxA")
Help?
Thanks,
Kris