Disable Ctrl-Alt-Delete, Alt-Tab, Ctrl-Esc

Using the SystemParametersInfo function you can trick Windows into thinking that the screen saver is running. Doing so disables the Ctrl-Alt-Delete key sequence from rebooting the PC and Alt-Tab from switching to another application. It also stops Ctrl-Esc from opening the Start Menu. For more information on this API, see my System Parameters Information example.

Download Source Code

Applies to

Windows 9x. Ctrl-Alt-Delete can be disabled on NT and Win2K but it is extremely risky. See the code below for details.

Form Code

Add this code to the Declarations Section:

   Const SPI_SCREENSAVERRUNNING = 97

   Private Declare Function SystemParametersInfo Lib "user32" _
      Alias "SystemParametersInfoA" (ByVal uAction As Long, _
      ByVal uParam As Long, ByVal lpvParam As Any, _
      ByVal fuWinIni As Long) As Long

Add a button with this code:

   Private Sub cmdEnable_Click()
      Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, "1", 0)
   End Sub

Add a button with this code:

    Private Sub cmdRelease_Click()
      Call SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, "1", 0)
   End Sub
Instructions

Download or enter in the source code. Press F5 to run the program.

  • Press Ctrl-Alt-Delete to bring up the Task List. Click Cancel.
  • Click Disable then hit Ctrl-Alt-Delete to see it has no effect.
  • Click Enable and then Ctrl-Alt-Delete to once again bring up the Task List. Hit Cancel.
  • Try the same using the Alt-Tab keys.
Windows NT and Windows 2000

You can disable Ctrl-Alt-Del on NT and 2K but this is very risky. It can prevent you from ever being able to log on again!

Be sure to enable Automatic Logon by specifying DefaultDomainName, DefaultUserName, DefaultPassword and AutoAdminLogin in the registry under Windows Login. Otherwise you will not be able to logon again. See Knowledge Base article Q114615 for details - there is a link on my links page. You may also want to read my disclaimer page.

After you set up automatic logon the logon dialog no longer appears at startup. You are then unable to logon as a different user until the automatic logon and below code is disabled in the registry. You may be able to temporarily bypass the automatic logon by holding down the Shift key as windows is starting

This code was donated by Paul Johnston.

Public Sub SetupScancodeMap()
   Dim bArray(1 To 48) As Byte
   
   On Error Resume Next
   If g_bDebugMode = True Then Exit Sub
   '
   ' Setup the keyboard scancode mapping to disable the Windows keys
   ' and Context menu keys
   '
   bArray(1) = &H0
   bArray(2) = &H0
   bArray(3) = &H0
   bArray(4) = &H0
   bArray(5) = &H0
   bArray(6) = &H0
   bArray(7) = &H0
   bArray(8) = &H0
   '
   ' Number of keys
   '
   bArray(9) = &H6
   bArray(10) = &H0
   bArray(11) = &H0
   bArray(12) = &H0
   '
   ' Windows key
   '
   bArray(13) = &H0
   bArray(14) = &H0
   bArray(15) = &H5B
   bArray(16) = &HE0
   '
   ' Windows key
   '
   bArray(17) = &H0
   bArray(18) = &H0
   bArray(19) = &H5C
   bArray(20) = &HE0
   '
   ' Windows menu key
   '
   bArray(21) = &H0
   bArray(22) = &H0
   bArray(23) = &H5D
   bArray(24) = &HE0
   '
   ' F10 key
   '
   bArray(25) = &H0
   bArray(26) = &H0
   bArray(27) = &H44
   bArray(28) = &H0
   '
   ' Left Ctrl-key
   '
   bArray(29) = &H0
   bArray(30) = &H0
   bArray(31) = &H1D
   bArray(32) = &H0
   '
   ' Left Alt-key
   '
   bArray(33) = &H0
   bArray(34) = &H0
   bArray(35) = &H38
   bArray(36) = &H0
   '
   ' Right Ctrl-key
   '
   bArray(37) = &H0
   bArray(38) = &H0
   bArray(39) = &H1D
   bArray(40) = &HE0
   '
   ' Right Alt-key
   '
   bArray(41) = &H0
   bArray(42) = &H0
   bArray(43) = &H3
   bArray(44) = &HE0
   '
   ' Null terminator
   '
   bArray(45) = &H0
   bArray(46) = &H0
   bArray(47) = &H0
   bArray(48) = &H0
   '
   ' Set the new registry value, does not take effect until the next reboot.
   ' You can use my registry module or your own routine to write the value to the registry.
   '
   Reg_SetKeyValue HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Keyboard
      Layout", "Scancode Map", bArray, REG_BINARY
   End Sub



About TheScarms
About TheScarms


Sample code
version info

If you use this code, please mention "www.TheScarms.com"

Email this page


© Copyright 2024 TheScarms
Goto top of page