Home All Groups Group Topic Archive Search About

Intercepting Ctrl+Alt+Del

Author
2 Feb 2006 7:04 PM
Vitalik
Hello,

In our application written in VB6 we use 3rd party controls from a vendor
who is no longer in business.  The problem with the controls occurs only
under WinXP and happens when users would like to lock their computers by
pressing first Ctrl+Alt+Del.  They may choose to go back to the desktop
immediately, but by that time our application is GPFd.  Upon further
investigation we noticed, that the controls in question must be enabled
(.Enabled = True), so quick workaround was to add an application wide
functionality to disable all controls on all open forms and link it to a
menu command.  This is good except that users need to remember to choose the
command before they press Ctrl+Alt+Del.  That's why I'm interested in
intercepting the keys combination in code if possible.  Any ideas are
welcome.

TIA,

Vitaliy
OAS Software Corp.

Author
2 Feb 2006 7:14 PM
Karl E. Peterson
Vitalik wrote:
> In our application written in VB6 we use 3rd party controls from a
> vendor who is no longer in business.  The problem with the controls
> occurs only under WinXP and happens when users would like to lock
> their computers by pressing first Ctrl+Alt+Del.  They may choose to
> go back to the desktop immediately, but by that time our application
> is GPFd.  Upon further investigation we noticed, that the controls in
> question must be enabled (.Enabled = True), so quick workaround was
> to add an application wide functionality to disable all controls on
> all open forms and link it to a menu command.  This is good except
> that users need to remember to choose the command before they press
> Ctrl+Alt+Del.  That's why I'm interested in intercepting the keys
> combination in code if possible.  Any ideas are welcome.

General concensus is, sorry, "forget it."  That key combination is handled
by msgina.dll, which you'd have to rewrite and replace.  Most shops would
(rightly) view this as a *serious* compromise of their security, and bar
such software from ever being installed.  I think you need to find another
way.
--
Working without a .NET?
http://classicvb.org/
Author
2 Feb 2006 8:21 PM
Vitalik
Hello Karl,

Thanks for your quick response.  I didn't have any high expectations simply
because I tried to subclass a form in a sample project and that didn't help
either. So, I guess I will stick with my "plan B" which is finding another
suitable set of controls (and get the source!) and replace our current ones.

Vitaliy

Show quoteHide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
news:ebr9YzCKGHA.668@TK2MSFTNGP11.phx.gbl...
> Vitalik wrote:
> > In our application written in VB6 we use 3rd party controls from a
> > vendor who is no longer in business.  The problem with the controls
> > occurs only under WinXP and happens when users would like to lock
> > their computers by pressing first Ctrl+Alt+Del.  They may choose to
> > go back to the desktop immediately, but by that time our application
> > is GPFd.  Upon further investigation we noticed, that the controls in
> > question must be enabled (.Enabled = True), so quick workaround was
> > to add an application wide functionality to disable all controls on
> > all open forms and link it to a menu command.  This is good except
> > that users need to remember to choose the command before they press
> > Ctrl+Alt+Del.  That's why I'm interested in intercepting the keys
> > combination in code if possible.  Any ideas are welcome.
>
> General concensus is, sorry, "forget it."  That key combination is handled
> by msgina.dll, which you'd have to rewrite and replace.  Most shops would
> (rightly) view this as a *serious* compromise of their security, and bar
> such software from ever being installed.  I think you need to find another
> way.
> --
> Working without a .NET?
> http://classicvb.org/
>
>
Author
2 Feb 2006 8:14 PM
J French
Show quote Hide quote
On Thu, 2 Feb 2006 13:04:29 -0600, "Vitalik" <addr***@domain.com>
wrote:

>Hello,
>
>In our application written in VB6 we use 3rd party controls from a vendor
>who is no longer in business.  The problem with the controls occurs only
>under WinXP and happens when users would like to lock their computers by
>pressing first Ctrl+Alt+Del.  They may choose to go back to the desktop
>immediately, but by that time our application is GPFd.  Upon further
>investigation we noticed, that the controls in question must be enabled
>(.Enabled = True), so quick workaround was to add an application wide
>functionality to disable all controls on all open forms and link it to a
>menu command.  This is good except that users need to remember to choose the
>command before they press Ctrl+Alt+Del.  That's why I'm interested in
>intercepting the keys combination in code if possible.  Any ideas are
>welcome.

See whether this works for disabling the keys
(your real solution is to ditch the 3rd party junk)

Option Explicit

' Disable Windows Key
' and Ctl Alt Delete

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 Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim Mask%
    Mask = vbCtrlMask + vbAltMask
    'If (Shift And Mask) = Mask Then
       If KeyCode = vbKeyDelete Then
          Me.Print "Gottit"
       End If
    'End If
End Sub

Private Sub Form_Load()
    Command1.Caption = "Stop Keys"
    Command2.Caption = "Allow Keys"
End Sub

Private Sub Command1_Click()
   SystemParametersInfo 97, True, "1", 0
End Sub

Private Sub Command2_Click()
    SystemParametersInfo 97, False, "1", 0
End Sub
Author
2 Feb 2006 8:30 PM
Jeff Johnson [MVP: VB]
Show quote Hide quote
"J French" <erew***@nowhere.uk> wrote in message
news:43e26800.119404801@news.btopenworld.com...

> ' Disable Windows Key
> ' and Ctl Alt Delete
>
> 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 Sub Command1_Click()
>   SystemParametersInfo 97, True, "1", 0
> End Sub

Are you sure SPI_SETSCREENSAVERRUNNING works in Windows XP? I thought that
was only for non-NT-based OSes.
Author
3 Feb 2006 11:35 AM
J French
On Thu, 2 Feb 2006 15:30:35 -0500, "Jeff Johnson [MVP: VB]"
<i.get@enough.spam> wrote:

<snip>

>Are you sure SPI_SETSCREENSAVERRUNNING works in Windows XP? I thought that
>was only for non-NT-based OSes.

You are probably right - it was getting late