Home

Since 31.05.1999
  • How to disable task switching and other system functions accessed through key combinations such as CTRL+ESC and CTRL+ATL+DEL on Win32 Platforms.


  • Windows 95 and Windows 98 Applications can enable and disable ALT+TAB and CTRL+ESC; for example, by calling SystemParametersInfo (SPI_SETSCREENSAVERRUNNING). To disable ALT_TAB and CTRL+ESC set the uiParam parameter to TRUE or FALSE to enable the keys.

    Have a look at Winctrl A Free software

    UINT nPreviousState;
    // Disables task switching SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
    // Enables task switching SystemParametersInfo (SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
    Applications that use SystemParametersInfo (SPI_SETSCREENSAVERRUNNING) to disable task switching must remember to enable task switching before exiting. Otherwise, task switching remains disabled after the process terminates.

    Windows NT 4.0 Service Pack 3 and later Windows 2000 Applications can disable ALT+TAB or CTRL+ESC by installing a low-level keyboard hook. A low-level keyboard hook is installed by calling SetWindowsHookEx.

    LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
    {
    KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
    BOOL bControlKeyDown = 0;
    switch (nCode)
    {
    case HC_ACTION:
    {
    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);
    }
    NOTE: Although a low-level keyboard hook gets notified when CTRL+ALT+DEL is pressed, it cannot prevent the CRTL+ALT+DEL from being handled by the system. Another option available is to install a keyboard filter driver, that can prevent keystrokes from being sent to the system, including CTRL+ALT+DEL. Consult the Windows NT DDK documentation for more information on keyboard filter drivers.

    Windows NT 4.0 Service Pack 2 and earlier, Windows NT 3.51 and earlier Applications can disable CTRL+ESC system-wide by replacing the Windows NT Task Manager, however this is not recommended.
    Applications can disable ALT+TAB and ALT+ESC when the application is running by registering hotkeys for the ALT+TAB and ALT+ESC combinations by calling RegisterHotKey.