Re: GetModuleHandle in DllMain?
On Fri, 17 Jul 2009 19:39:13 -0400, "Igor Tandetnik" <itandetnik@mvps.org>
wrote:
|Or, you could just use
|the hook for all your message intercepting needs.
Code below. Everything in DllMain succeeds. But my hookproc is never called.
Any ideas?
LRESULT CALLBACK CallWndProc(INT nCode, WPARAM wParam, LPARAM lParam )
{
Beep(880,100);
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
static BOOL bInit = FALSE;
if ( !bInit )
{
Beep(440,300); // I hear this one!
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
if ( hUser32 == NULL ) Beep(880,200);
pFindWindowW = ( FWW_TYPE ) GetProcAddress(hUser32, "FindWindowW");
if ( pFindWindowW == NULL ) Beep(880,200);
hWndOL = pFindWindowW(L"rctrl_renwnd32", L"Inbox - Microsoft Outlook");
if ( hWndOL == NULL ) Beep(880,200);
pSetWindowsHookEx = (SWHEx_TYPE) GetProcAddress(hUser32,
"SetWindowsHookExW");
if ( pSetWindowsHookEx == NULL ) Beep(880,200);
pGetWindowThreadProcessId = (GWTPI_TYPE) GetProcAddress(hUser32,
"GetWindowThreadProcessId");
if ( pGetWindowThreadProcessId == NULL ) Beep(880,200);
hHook = pSetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC) CallWndProc,
NULL, pGetWindowThreadProcessId(hWndOL, NULL));
if ( hHook == NULL ) Beep(880,200);
bInit = TRUE;
}
return TRUE;
}
--
- Vince