WH_KEYBOARD_LL的hook问题,求高手指点,:)
我定义的全局钩子,安装函数如下:
DllExport void WINAPI InstallLaunchEv()
{
Hook=(HHOOK)SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)LauncherHook, theApp.m_hInstance,0);
}
钩子函数如下:
LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
{
// By returning a non-zero value from the hook procedure, the
// message does not get passed to the target window
KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *)lParam;
BOOL bControlKeyDown = 0;
switch (nCode)
{
case HC_ACTION:
{
// Check to see if the CTRL key is pressed
bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
// Disable CTRL+ESC
if (pkbhs->vkCode == VK_ESCAPE && bControlKeyDown)
return 1;
// Disable ALT+TAB
if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN)
return 1;
// Disable ALT+ESC
if (pkbhs->vkCode == VK_ESCAPE && pkbhs->flags & LLKHF_ALTDOWN)
return 1;
break;
}
default:
break;
}
return CallNextHookEx (Hook, nCode, wParam, lParam);
}
编译出现一下问题:
error C2065: 'WH_KEYBOARD_LL' : undeclared identifier
error C2065: 'KBDLLHOOKSTRUCT' : undeclared identifier
error C2065: 'pkbhs' : undeclared identifier
error C2059: syntax error : ')'
error C2227: left of '->vkCode' must point to class/struct/union
error C2227: left of '->vkCode' must point to class/struct/union
error C2227: left of '->flags' must point to class/struct/union
error C2065: 'LLKHF_ALTDOWN' : undeclared identifier
error C2227: left of '->vkCode' must point to class/struct/union
error C2227: left of '->flags' must point to class/struct/union
Error executing cl.exe.
LaunchDLL.dll - 10 error(s), 0 warning(s)