Okay, I am successfully loading a DLL with:
But, I'm trying to figure out how to call the function/sub at fuctionAddress. I know you can use CallWindowProc, but apparently I'm not using it quite right...Code:LibraryHandle = LoadLibrary("C:\test.dll") functionAddress = GetProcAddress(LibraryHandle, "ShowMessage")
I downloaded a project that uses CallWindowProc to call a sub in the same program:
However, I can't get it to call my DLL... Do I have to initialize my DLL first after loading it?Code:Option Explicit 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 ShowMessage(msg As String, ByVal nUnused1 As Long, ByVal nUnused2 As Long, ByVal nUnused3 As Long) MsgBox msg End Sub Private Function ProcPtr(ByVal nAddress As Long) As Long ProcPtr = nAddress End Function Public Sub Haha() Dim sMessage As String Dim nSubAddress As Long sMessage = InputBox("Please input a short message") nSubAddress = ProcPtr(AddressOf ShowMessage) CallWindowProc nSubAddress, VarPtr(sMessage), 0&, 0&, 0& End Sub




Reply With Quote