Vista - how to hook keyboard strikes such as CTRL+ALT+DEL?

joker77

Freshman
Joined
Sep 16, 2005
Messages
38
Location
Dublin
Hi,

I recently upgraded my machine to Vista, and am loving it! Finding it nice and light, and the UI is really great so hats off!

At the moment I'm prototyping a kiosk type Windows Forms application to run on Vista. I can start the application running on O/S load by modifying the following reg key to point to my application rather than Explorer.exe:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

The next thing I need to do is to stop the User breaking out of my application once it's running, so I'll need to disable key combinations like ALT+F4, CTRL+ALT+DEL etc...

I found a great article on how to do this on XP here:
http://www.codeguru.com/columns/VB/article.php/c4831/

The code allows you to hook the keyboard to catch certain key combinations, in this example ATL+TAB, ALT+ESC and CTRL+ESC. I've been playing round with the code on Vista, and have come up with the following behaviour:
The only one that is kind of working is the ALT+TAB - the code catches the combination and most of the time the window does not switch, but sometimes even though the code catches the combination the focus shifts to the next window (for example if you press it in a few times in quick succession). For ALT+ESC, the code catches the combination but focus still shifts to the next window, for CTRL+ESC the code catches the combination but the Start Menu appears (similar to pressing the Windows key).

There may of course be another way around this using managed code in .NET 2005 (the example above uses the Windows APIs SetWindowsHookEx, GetAsyncKeyState and CallNextHookEx).

The question is do you know any way on Vista to programmatically intercept key combinations like ALT+F4, CTRL+ALT+DEL? (seeing this low-level way is not really working)

Thanks
 
It turned out the simply act of me putting a message box in the code was causing the keyboard hooking to stop working, I removed the message box and it works a treat on Vista as well as XP.

I still haven't found anywhere to disable CTRL+ALT+DEL though, even though I can catch it along with the other combinations, I cannot stop it.

In terms of locking down the computer, not allowing the User to Log Off, Display Task Manager, or Shut down, I found a great article here:

http://www.codeguru.com/Cpp/W-P/system/security/article.php/c5737/

In Vista I can switch off all options except 'Switch User', so when the User presses CTRL+ALT+DEL they still get the Switch user option.

Any ideas how to get around this one?
 
Back
Top