如题,如何用LoadLibrary动态调用API?例如动态调用ShellExecute打开网页.最好有具体代码!

解决方案 »

  1.   

    http://topic.csdn.net/u/20100326/18/8f87567c-a66e-4f91-b36f-164b30429672.html
      

  2.   

    《Call and Return Values From API functions by Name, without Declare》   
    http://www.freevbcode.com/ShowCode.Asp?ID=1863
    http://www.freevbcode.com/code/APIByName.zip
      

  3.   

    我的博客里有详细的代码范例
    http://blog.csdn.net/SupermanKing/archive/2008/09/28/2992218.aspx
      

  4.   

    Create a new project and add this code to Form1
    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
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'We're going to call an API-function, without declaring it!
        Dim lb As Long, pa As Long
        'map 'user32' into the address space of the calling process.
        Lb = LoadLibrary("user32")
        'retrieve the address of 'SetWindowTextA'
        pa = GetProcAddress(lb, "SetWindowTextA")
        'Call the SetWindowTextA-function
        CallWindowProc pa, Me.hWnd, "Hello !", ByVal 0&, ByVal 0&
        'unmap the library's address
        FreeLibrary lb
    End Sub