|
-
Feb 25th, 2006, 10:37 PM
#1
Thread Starter
Hyperactive Member
Call External Function
How do I call an external function? I tried this code but it always crashes:
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 Form_Load()
On Error Resume Next
Dim lb As Long, pa As Long
lb = LoadLibrary("zlib.dll")
pa = GetProcAddress(lb, "compress")
CallWindowProc pa, Me.hWnd, "Hello !", ByVal 0&, ByVal 0&
FreeLibrary lb
End Sub
Last edited by abazabam; Feb 25th, 2006 at 11:05 PM.
-
Feb 25th, 2006, 11:00 PM
#2
Member
Re: Call External Function
Replace private with public if those are in modules
Edit:
i think i misunderstood you
-
Feb 25th, 2006, 11:05 PM
#3
Thread Starter
Hyperactive Member
Re: Call External Function
That's not the problem. Whenever I try to run the code, VB crashes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|