LRESULT CALLBACK LowLevelKeyboardPorc(int nCode,WPARAM wParam,LPARAM lParam)//屏蔽按键的真正实现方法
{
BOOL fEatKeystrole = FALSE;
if (nCode == HC_ACTION)
{
switch (wParam)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
{
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
if (p->vkCode == VK_LWIN || p->vkCode == VK_RWIN)//
{
fEatKeystrole = TRUE;
}
// //Tab + Alt
/*((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
//Esc + Alt
|| ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0))
//Esc + Ctrl
|| ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0))
//Ctrl + Space
|| (((GetKeyState(VK_CONTROL) & 0x8000) != 0) && (p->vkCode == VK_SPACE));
*/
}
break;
}
}
return(fEatKeystrole?1:CallNextHookEx(NULL,nCode,wParam,lParam));
}
BOOL CXXXDlg::installhook(void)
{
HINSTANCE hins=AfxGetInstanceHandle();
Hook = SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)LowLevelKeyboardPorc,hins,0);
return (BOOL)Hook;
}
BOOL CXXXDlg::OnInitDialog()
{
//前面代码 系统默认,
SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);//全屏后一直在前端显示
HWND hWnd = ::FindWindow(_T("Shell_TrayWnd"),NULL);//取消任务栏,开始菜单
HWND hButton =::FindWindow(NULL, _T("Start"));//取消开始菜单 ,XP下不成功
if (hWnd&& hButton)
{
// static BOOL bShow = FALSE;
::ShowWindow(hWnd, SW_HIDE );
::ShowWindow(hButton,SW_HIDE);
}
installhook();//加载勾子
return TRUE;
}
//卸载
UnhookWindowsHookEx(g_hhkLowLevel,Kybd);//这个参数不对
http://blog.csdn.net/eplanet/article/details/1789941