HOWTO: Block CTRL+ALT+DEL and ALT+TAB in Windows 95/98 in VBID: Q154868
|
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.
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."
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
SystemParametersInfo is documented in the Win32 SDK available in the MSDN/Visual Basic Starter Kit that can be installed from the CD-ROM version of Visual Basic 4.0, Professional and Enterprise Editions. Install by running SETUP.EXE in the MSDN directory on the CD-ROM. It is also available in the MSDN Development Library that is available under subscription from Microsoft.
Additional query words:
reboot kbAPI kbSDKWin32 kbVBp400 kbVBp600 kbVBp500 kbVBp kbDSupport
kbdsd KBWIN32SDK
Keywords :
Version : WINDOWS:4.0,5.0,6.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 13, 1999