• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

How to Block Ctrl+Alt+Del and Alt+Tab on NT

I want that Ctrl+Alt+Del will do nothing on NT. also Alt+Tab. Is there an easy way to do it?
I tried to catch it with PreTranslateMessage bu it didn't help.
thanks.
0
michali
Asked:
michali
  • 8
  • 6
  • 2
  • +5
1 Solution
 
KangaRooCommented:
0
 
jkrCommented:
>>I want that Ctrl+Alt+Del will do nothing on NT. also
>>Alt+Tab. Is there an easy way to do it?

There's only a very hard way to do this - writing your own GINA replacement DLL...
0
 
michaliAuthor Commented:
Adjusted points to 300
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ZoppoCommented:
ALT-TAB is easy: Just use the RegisterHotKey() function to register ALT-TAB as a hotkey for your application.
0
 
ZoppoCommented:
In MSDN article ID: Q226359 I found some information how to disable CTRL-ESC and ALT-ESC using a 'low level keyboard hook'.

hope that helps,

ZOPPO
0
 
ZoppoCommented:
Some assistance for writing your own GINAdll can be found at http://www.codeguru.com/mfc/comments/2574.shtml
0
 
diplodocusCommented:
i never do it but see this article
it could help you


Prevent DirectDraw from releasing exclusive control of the display or rebooting if the user presses CTRL + ALT + DEL (exclusive mode only).


http://msdn.microsoft.com/library/psdk/directx/ddover_14fr.htm

good luck.
0
 
TryCommented:
You can prevent the CTRL+ALT+DEL and ALT+TAB key combinations from bringing up a task list in Windows 95 by calling the SystemParametersInfo function in the Win32 API. A step-by-step example of this appears below.

NOTE: This is possible only in Windows 95.

MORE INFORMATION:

Sometimes it is necessary for a program to prevent the use of the CTRL+ALT+DEL key combination to bring up the Close Program task list to end a task or shut down Windows 95 and to prevent the use of the ALT+TAB key combination to switch tasks. The following technique uses the SystemParametersInfo API to trick Windows 95 into thinking that a screen saver is running. As a side effect, CTRL+ALT+DEL and ALT+TAB are disabled.

The Win32 SDK states:

"SPI_SCREENSAVERRUNNING Windows 95: Used internally; (applications should not use this flag.)

Windows NT: Not supported."

Note that disabling CTRL+ALT+DEL is not recommended because the Close Program dialog box was created to enable users to terminate misbehaving applications. If a program "hangs" while CTRL+ALT+DEL is disabled, it may not be possible to terminate it by any method other than rebooting the machine, which could result in the loss of data. Also, this technique may not work in future versions of Windows.


Step-by-Step Example:

Start a new Standard EXE project. Form1 is created by default.

Add two CommandButton controls (Command1 and Command2) to Form1.

Add the following code to Form1's General Declarations section:


      Private Const SPI_SCREENSAVERRUNNING = 97&
      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 Sub Form_Load()
         Command1.Caption = "Disabled"
         Command2.Caption = "Enabled"
      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

      Private Sub Command1_Click()
         Dim lngRet As Long
         Dim blnOld As Boolean
         lngRet = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, _
         blnOld, _
            0&)
      End Sub

      Private Sub Command2_Click()
        Dim lngRet As Long
        Dim blnOld As Boolean
        lngRet = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, _
        blnOld, _
           0&)
      End Sub


Press the F5 key to run the program, and click the "Disabled" CommandButton. CTRL+ALT+DEL and ALT+TAB are disabled. Click the "Enabled" CommandButton to enable CTRL+ALT+DEL and ALT+TAB again.
0
 
ZoppoCommented:
Hi diplodocus: taking a look to help for SetCooperativeLevel() you'll see it requires at least Win98/NT2000 and only works in full screen mode for this purpose.

Hi try: michali needs it for NT, not Win9x
0
 
michaliAuthor Commented:
See Zoppo note
0
 
michaliAuthor Commented:
Zoppo -
about the RegisterHotKey - Indeed it helps. thanks.
I have a problems with Ctrl+Alt+Del.
also I'm trying the 'low level keyboard hook'.
meanwhile your answer is the most helpfull.
0
 
SwordSaintCommented:
did u try the combiantions of KeyDown and KeyPress messages? U can set it to do nothing when the combination of these keys appeared.
0
 
michaliAuthor Commented:
Those are system combination and therefore the system handles them first and the application can not do anything.
0
 
michaliAuthor Commented:
Does anyone know how to use the keyboard hook functions. any example on that?
0
 
ZoppoCommented:
You can find some links and code snippets in MSDN:

MSDN Article ID: Q66989
MSDN Article ID: Q179905
MSDN Article 'Win32 Hooks'

ZOPPO
0
 
michaliAuthor Commented:
Do I have to use a dll?
0
 
cwreaCommented:
A system-wide keyboard hook must reside in a DLL.  However, you can't trap CTRL-ALT-DEL with a keyboard hook.  You have no choice but to write a replacement GINA.DLL.  The only other way to do it is to replace the keyboard driver and trap it at a level lower than the system does.
0
 
michaliAuthor Commented:
I'm trying to use the WH_KEYBOARD_LL kook but I can't pass  compilation when using WH_KEYBOARD_LL, although I included winuser.h and I have NT 4 + SP3
any idea?
0
 
cwreaCommented:
You can't use that hook to trap CTRL-ALT-DEL on Windows NT.  No point in barking up that tree.
0
 
michaliAuthor Commented:
Zoopo - I want to give you score about your answer but I don't know how to do it.
maybe you will answer again so I can grade it.
your answer was very helpfull for me.
thanks
0
 
ZoppoCommented:
you're welcome :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 6
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now