Results 1 to 3 of 3

Thread: Call External Function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    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.

  2. #2
    Member Mephy's Avatar
    Join Date
    Dec 2005
    Posts
    52

    Re: Call External Function

    Replace private with public if those are in modules
    Edit:
    i think i misunderstood you

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    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
  •  



Click Here to Expand Forum to Full Width