Error in CBT_HOOK function
-
i write a global CBT_HOOK function in a win32 DLL ,and i want to send a message to the DLL's calling windows.But it doesnt work. Here is my code:
HWND hCallWnd = NULL; // a global var to save the Dll's Caller LRESULT CALLBACK CbtProc(int nCode,WPARAM wParam,LPARAM lParam) { switch(nCode) { case HCBT_CREATEWND: SendMessage(hCallWnd,MyMsgID,0,0); // to Send a msg break; } return CallNextProc(nCode,...); } void InstallHook(HWND hcallwnd) { SetWindowsHookEx(WH_CBT,CbtProc,DllHandle,0); // set a global hook hCallWnd = hcallwnd; // save the Caller's handle }
the Error is : in InstallHook() function,the hCallWnd's value is correct. But in CALLBACK CbtProc() function, the hCallWnd's value is always ZERO! so my SendMessage() doesnt work at all. Who can point out reason ? -
i write a global CBT_HOOK function in a win32 DLL ,and i want to send a message to the DLL's calling windows.But it doesnt work. Here is my code:
HWND hCallWnd = NULL; // a global var to save the Dll's Caller LRESULT CALLBACK CbtProc(int nCode,WPARAM wParam,LPARAM lParam) { switch(nCode) { case HCBT_CREATEWND: SendMessage(hCallWnd,MyMsgID,0,0); // to Send a msg break; } return CallNextProc(nCode,...); } void InstallHook(HWND hcallwnd) { SetWindowsHookEx(WH_CBT,CbtProc,DllHandle,0); // set a global hook hCallWnd = hcallwnd; // save the Caller's handle }
the Error is : in InstallHook() function,the hCallWnd's value is correct. But in CALLBACK CbtProc() function, the hCallWnd's value is always ZERO! so my SendMessage() doesnt work at all. Who can point out reason ?