HOWTO: Disable Task Switching on Win32 PlatformsID: Q226359
|
This article describes how to disable task switching and other system functions accessed through key combinations such as CTRL+ESC and CTRL+ATL+DEL on Win32 Platforms.
UINT nPreviousState;
// Disables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
// Enables task switching
SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 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 ATL+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;
// Disable the WINDOWS key
if (pkbhs->vkCode == VK_LWIN || pkbhs->vkCode == VK_RWIN)
return 1;
break;
}
default:
break;
}
return CallNextHookEx (hHook, nCode, wParam, lParam);
}
Q89373 Replacing the Windows NT Task Manager
Additional query words: CTRL+ESC CTL+ESC ALT+TAB ALT+ESC CTRL+ALT+DEL CTL+ALT+DEL SetWindowsHookEx WH_KEYBOARD_LL SystemParametersInfo SPI_SCREENSAVERRUNNING SPI_SETSCREENSAVERRUNNING
Keywords : kbHook kbInput kbNTOS400 kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS95 kbWinOS98
Version : winnt:3.51,4.0
Platform : winnt
Issue type : kbhowto
Last Reviewed: May 3, 1999