Solved

Disable Ctrl-Alt-Del from a form

Posted on 2002-06-28
10
597 Views
Last Modified: 2012-06-27
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!
0
Comment
Question by:jmerritt
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7116733
i think that in queryunload event of form you could use:
if unloadmode = 2 or unloadmode=3 then
cancel=true
end if
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 7116765
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
 
LVL 4

Expert Comment

by:frankd
ID: 7116969
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7117076
i was with Tim in first place, so i posted a different way.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7121233
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:frankd
ID: 7121580
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 7121589
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
 
LVL 1

Author Comment

by:jmerritt
ID: 7121599
Thanks anyway.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7121632
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
 
LVL 4

Expert Comment

by:frankd
ID: 7122350
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now