Click to See Complete Forum and Search --> : Disabling Ctrl Alt Del keys
HanneSThEGreaT
August 2nd, 2001, 05:10 PM
A nice funtion to disable all the Ctrl + Alt + Del, Ctrl + Esc keys to prevent the user from exiting the form - you can also set the form's Border Style property to 0 - None.
Here's the code.
First declare the API function.
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 'API Function to disable keys
Then the sub (Also in General Declarations)
Sub DisableCtrlAltDel(bDisabled as Boolean)
' Disables Control Alt Delete Breaking
'as well as Ctrl-Escape
Dim X as Long
X = SystemParametersInfo(97, bDisabled, CStr(1), 0)
End Sub
'to disable CtrlAltDel do a call as such...
'Call DisableCtrlAltDel(true), '
'to re-enable use false instead of true in the call.
To call the function just do like this:
Call DisableCtrlAltDel(false) 'can use true as well
Remeber to re-enable it when the program exits!
Peace!
F. T. W.
jamesgriff
September 29th, 2001, 01:46 PM
WOW
That's brilliant coding.
However, it does not appear to work on Windows 2000 and I was wondering if you knew why it did not work, and how I can make it work.
Thanks
Bye
WWWhy not visit James Griffiths' web site @ www.jamesgriff.co.uk
HanneSThEGreaT
September 29th, 2001, 06:27 PM
I haven't tested it at all on Windows 2000. Sorry... I'll do some research, and when I find the answer I'll let you know, because now I want to know why it doesn't work on Win2000 as well.
Thanx for letting me know!
Hannes
F. T. W.
shree
September 30th, 2001, 12:11 PM
Somebody some time ago asked how Print Screen could be disabled. Maybe you have the solution.
Cimperiali
October 1st, 2001, 02:03 AM
Joust a thougt:
If you are able to intercept the printscreen keystroke, you can clear the clipboard object....
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Iouri
October 1st, 2001, 09:47 AM
W2000 is based on NT platform. You cannot block alt+ctrl+delete on Windows NT. Even using a low-level keyboard hook doesn't work.
NT traps this key combination before the event handler gets it and automatically handles it. The only way
that you could do anything about it would be to write your own dll which receives this event from the
O/S however this is an extremely complex task.
Iouri Boutchkine
iouri@hotsheet.com
Clearcode
October 1st, 2001, 10:14 AM
This works by convincing windows that a screensaver is running.
In Win9x, it is the responsibility of the screensaver to validate the password so in response to getting the "Screen Saver Active" message, windows 9x disables the CTRL+ALT+DEL hotkey combination.
Because of the enourmous potential for writing a malicious screensaver application this functionality was removed from WinNT/Win2k and it is now the responsibility of the OS to handle locking/unlocking a machine.
Note that you should use the constant value:
private Const SPI_SCREENSAVERRUNNING = 97
to make this code more readable.
For a full list of system parameter info constants, see http://www.merrioncomputing.com/EventVB/enSystemParametersInfo.html
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.