Microsoft KB Archive/154868

-

The information in this article applies to:


 * Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
 * Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 32-bit only, for Windows, version 4.0

-

SUMMARY
It is possible to prevent the CTRL+ALT+DEL and ALT+TAB key combinations from bringing up the task list in Windows 95 by calling a function in the Win32 API. This article demonstrates this procedure.

NOTE: This is possible only in Windows 95 and Windows 98.

MORE INFORMATION
It may be necessary for a program to prevent users from pressing the CTRL+ALT+DEL key combination to bring up the Close Program task list in Windows 95 or Windows 98 from where they can end a task or shut down the system.

This can be done using the SystemParametersInfo API. A sample program demonstrating this is given below.

Note that disabling CTRL+ALT+DEL is not recommended because the Close Program dialog was created to allow misbehaving applications to be terminated. If a program "hangs" while CTRL+ALT+DEL is disabled, it may not be possible to terminate it by any method other than a hardware reboot of the machine, possibly resulting in loss of data. Also, this technique may not work in future versions of Windows.

The technique involves tricking Windows 95 or Windows 98 into thinking that a screen saver is running. A side effect of this is that CTRL+ALT+DEL no longer has any effect.

The Win32 SDK states:

"'SPI_SCREENSAVERRUNNING Windows 95: Used internally; applications should not use this flag. Windows NT: Not supported.'"

Step-by-Step Example
 Start a new Visual Basic project. Form1 is created by default. Add two Command buttons to Form1.  Put the following code into the General Declarations section of Form1:

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

Private Const SPI_SCREENSAVERRUNNING = 97

Private Sub Command1_Click Dim ret As Integer Dim pOld As Boolean ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0) End Sub

Private Sub Form_Load Command1.Caption = "Disabled" Command2.Caption = "Enabled" End Sub

Private Sub Command2_Click Dim ret As Integer Dim pOld As Boolean ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0) End Sub

Private Sub Form_Unload(Cancel As Integer) ' re-enable Ctrl+Alt+Del and Alt+Tab before the program terminates Command2_Click End Sub  Run the project and click the Disable button to test. Click the Enable button to enable CTRL+ALT+DEL and ALT+TAB again.