我想设一个全局钩子,屏蔽掉发送到指定进程的鼠标消息,请问怎么在鼠标钩子回到函数中判断当前钩到的鼠标消息是发送到哪个进程的?
------解决方案--------------------------------------------------------
#pragma data_seg("ShareData")
DWORD g_dwTargetProcessId; //要屏蔽鼠标消息的进程ID
#pragma data_seg()
void SetTargetProcessId(DWORD dwProcessId)//导出这个函数,在安装鼠标钩子之前调用
{
g_dwTargetProcessId = dwProcessId;
}
LRESULT WINAPI MouseHookProc(int nCode,WPARAM wParam ,LPARAM lParam){
LPMOUSEHOOKSTRUCT lpMouse = (MOUSEHOOKSTRUCT FAR*)lParam;
DWORD dwProcessId;
::GetWindowThreadProcessId(lpMouse->hwnd, &dwProcessId);
if(dwProcessId == g_dwTargetProcessId)
return 0;
return CallNextHookEx(g_hMouseHook,nCode,wParam,lParam);
}