
we should retrieve the handle of our VB App in the DLL_PROCESS_ATTACH routine. (Note: There are many things that could be made more efficient e.g. It should be fairly self-explainatory, but let me know if you have any questions. But I am unsuccessful using the real window I want to monitor although Spy++ can find the window.ġ) In the DLL, I was not seeing the WM_SETTEXT message until I changed the type of hook I set in my VB app from WH_GETMESSAGE to WH_CALLWNDPROC.Įnd FunctionNotice we are checking for our customized message (WM_USER+800), and comparing the wParam parameter to see which menu item was clicked. This was fine for the easily found systray clock. Anyway, I decided to "cheat" so that when I got the notification from the DLL that a WM_SETTEXT occurred, I would have my VB app do a GetWindowText with FindWindow code in the VB app. There may be a solution in the so-called undocumented documentation at using VarPtr and StrPtr. The problem there was that I could not convert the string pointer from the DLL back to a VB string in the VB app. I used FindWindow code in the DLL to find the clock and also to find my subclassed PictureBox which would receive notifications. The furthest I got was by testing on the clock in the system tray as the window to monitor for WM_SETTEXT messages. I welcome your comments to my statements and direct questions in #3,4,5 and 6. I seem to be having some success, but I also keep bumping into walls. Receving process via ReadProcessMemory(). WM_USER+500) and pass a pointer to a memory location (in the external process) which can be read by our a hidden picturebox).ī) Create a customized message (i.e. WinProc = CallWindowProc(lPrevProc, hwnd, uMsg, wParam, lParam)Ī) Designate a window to receive the messages directly (i.e. Public Function WinProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long SetWindowLong hwnd, GWL_WNDPROC, lPrevProc Public Sub UnSubclassWnd(ByVal hwnd As Long) LPrevProc = GetWindowLong(hwnd, GWL_WNDPROC)Ĭall SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WinProc) Public Sub SubClassWnd(ByVal hwnd As Long) Private Declare Function CallWindowProc Lib "user32.dll" 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 Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Code: Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
