UnhookWindowsHookEx(m_hMsgHook); // 解除勾子
//键盘勾子
LRESULT CALLBACK msghook(UINT nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{
CallNextHookEx(m_hHook, nCode, wParam, lParam);
return 0;
}
return CallNextHookEx(m_hHook, nCode, wParam, lParam);
}
m_hHook = SetWindowsHookEx(WH_KEYBOARD,
(HOOKPROC)msghook,
hInst,
0);
//消息勾子
m_hMsgHook = SetWindowsHookEx(WH_GETMESSAGE,
(HOOKPROC)GetMsgProc,
hInst,
0);
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode < 0 ) // do not process message
return CallNextHookEx(m_hMsgHook, nCode,
wParam, lParam);
PMSG pMsg = (PMSG)lParam;
if ( pMsg->message == WM_CHAR )
{
}
return CallNextHookEx(m_hMsgHook, nCode, wParam, lParam);
}
//鼠标勾子
m_hook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)HookMouse, NULL, GetCurrentThreadId());
LRESULT HookMouse(int nCode, WPARAM wParam, LPARAM lParam)
{
if ( nCode >= 0 )
{
MOUSEHOOKSTRUCT *pMouseInfo = (MOUSEHOOKSTRUCT *)lParam;
}
return CallNextHookEx(m_hook, nCode, wParam, lParam);
}
阅读(1544) | 评论(0) | 转发(0) |