|
从visual c++模块与项目实战大全书中代码部分:
钩子DLL中
/// 底层键盘钩子函数
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HC_ACTION)
{
//BOOL bctrl = GetAsyncKeyState(VK_SNAPSHOT)>>((sizeof(SHORT)*8)-1);
//KBDLLHOOKSTRUCT* pStruct = (KBDLLHOOKSTRUCT*)lParam;
//LPDWORD tmpVirtualKey = g_lpdwVirtualKey;
if (GetAsyncKeyState(VK_DELETE))
{
PostMessage(g_hWnd,WM_MY_SHORTS,0,1);
return TRUE;
}
}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
如按原书代码可得到CTRL键信息,但不能指定接收到如DELETE或ESC等按键信息.
按此全键盘按键的信息都会收到,不单Delete键.请大师看看如何实现收到指定按键信息及可以屏蔽按键功能.如截屏按键功能. |
|