CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Mar 2005
    Posts
    22

    Systemwide hook from C++ Borland Builder

    Hi,
    I created simple DLL in VS2005.
    Code:
    TEST_API int InstallHook(void)
    {
    	hHooks = SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC) GetMsgProc, (HINSTANCE) hInstance, 0);
    	return (int)hHooks; 
    }
    
    TEST_API int UnInstallHook(void)
    {
    	return UnhookWindowsHookEx(hHooks);
    }
    
    LRESULT CALLBACK GetMsgProc (int code, WPARAM wParam, LPARAM lParam )
    {
    	if (code < 0) return CallNextHookEx(hHooks, code, wParam, lParam);
    	MSG		*lpMsg;
    	lpMsg = (MSG *) lParam;
    //do something with msg
    	return CallNextHookEx(hHooks, code, wParam, lParam);
    }
    I want to use this dll with BCC to capture messages system wide. In my BCB application I call InstallHook from dll and hook installs fine. I've debugged the dll. It also uninstalls fine. Problem is GetMsgProc gets messages only from BCB application window. Last parameter in SetWindowsHookEx is 0 so hook should be systemwide. Why isn't this working like this?
    I found sample VB application which I modified to load this dll and from there it works for all applications. VB application was compiled in vc2005. Does it mean my problems are caused by BCC itself?
    Last edited by lechoo; April 19th, 2008 at 07:53 AM.

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

Featured