Disable Ctrl-Alt-Del from a form

I have one form in my app that I want to completely lock the end-user from exiting except by one command button.  I have disabled other controls and set the ControlBox property of the form to False.  I have set the BorderStyle to Fixed Single.  At this point, the only way they can exit the form is through Ctrl-Alt-Del.  I tried to cancel the Keycode value in the KeyDown event of the form when Shift = 6 (Ctrl+ALT) but I still brought up TaskManager when I hit the Del key.  I'm hesitant to modify Registry settings because if the computer goes down then an NT/2000 machine might never allow a log-on (requires Ctrl-Alt-Del).  If anybody has an idea I'd be greatly appreciative!  Thanks for your thoughts!
LVL 1
jmerrittAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
It isn't going to work on NT or any NT based O/S such as 2000 and XP. To trap the Ctrl+Alt+Delete key combination is impossible because it is handled by the GINA.DLL before it is actually processed by the keyboard buffer. This means that to do anything with this combination requires a complete rewrite of the underlying security of the operationg system GINA is responsible for authentication. It is possible to do as some companies such as Novell have done in association with Microsoft though I have never found anyone else willing to attempt this task.

It is possible in 9x and ME by use of the ScreenSaverIsRunning flag.

Option Explicit

Private 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

Private Const SPI_SETSCREENSAVERRUNNING = 97

Public Sub DisableCAD(Disabled As Boolean)

'SET DISABLED TO TRUE TO DISABLE CTRL-ALT-DELETE
'SET DISABLED TO FALSE TO RE-ENABLE

    Dim lRet As Long
    lRet = SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, _
      Disabled, 0&, 0&)
End Sub  

Code from http://www.freevbcode.com
0
 
Richie_SimonettiIT OperationsCommented:
i think that in queryunload event of form you could use:
if unloadmode = 2 or unloadmode=3 then
cancel=true
end if
0
 
frankdCommented:
Tim is right, I have seen products advertised that do this with NT but I have no experience with them.  

I use a package called Wonderware (Operator Interface Software for Machine controls) and they have a dll called keytrap.dll that does it even on NT,  the downside is that you have to have Wonderware running for it to work.  I do use it with NT. Then, within Wonderware I check who is logged on and if they have the proper security I enable the Ctrl-Alt-Del key combination.

Good luck.

Frank
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Richie_SimonettiIT OperationsCommented:
i was with Tim in first place, so i posted a different way.
0
 
TimCotteeHead of Software ServicesCommented:
Which version of wonderware do you use Frank, I am familiar with InTouch/InTrack 7.0 but had never come across the keytrap.dll
0
 
frankdCommented:
Tim,

I've used the keytrap dll in WW version 5.6 right up to the present version 7.11.  If you have the Knowledge base CD the complete description is listed.

Frank
0
 
TimCotteeHead of Software ServicesCommented:
Thanks Frank I may well look into that, though I try to avoid Wonderware as much as possible. I even wrapped all the InTrack functionality into a VB dll so that I could use it natively in VB with the ability to return some stuff as ADO recordsets rather than the garbled stuff that you sometimes get from it.

I must say that I think I now hate wonderware with a passion, especially when you compare it with VB, it may have improved in the last version or two but I doubt it somehow.
0
 
jmerrittAuthor Commented:
Thanks anyway.
0
 
TimCotteeHead of Software ServicesCommented:
I had a quick look Frank, and without installing WW on this machine I think it would actually be possible to get it to work, the dll is only there to respond to events raised by the keyboard driver (this is a replacement for the standard driver, which is why I guess you can do this). It would be possible to determine what the API calls for the dll would be and utilize these in VB proper. One day perhaps I will investigate this however it would be no good for jmerrit as it would be almost impossible to distribute and would also probably incur WW licensing problems as well.
0
 
frankdCommented:
Tim,

I agree with everything you said.  Right now I'm using VB to get data from InSql (Wonderware's wrapper) and it's a nightmare.

If it was my choice I'd stay away from WW as well, but my company is sold on it (about 50 licenses).

Frank
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.