user528033
user528033

Reputation: 11

Detect when a user presses CTRL -ALT - DEL or Window + L in VB.net

I'm trying to find out a way to detect when ever the user presses CTRL -ALT - DEL or Window + L to lock the PC.

The code I'm using is

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If (GetAsyncKeyState(17) AndAlso GetAsyncKeyState(18) AndAlso GetAsyncKeyState(46)) Or ((GetAsyncKeyState(91) Or GetAsyncKeyState(92)) AndAlso GetAsyncKeyState(76)) Then
        Msgbox ("Yes")
    End If
End Sub

However, as soon as the user presses CTRL-ALT-DEL the Windows Security Screen comes up and it is too fast for VB to detect that the keys have been pressed.

I did a little reaserch on how to work around this issue and found that a GINA stub can be written which can delay the Windows Security Screen by some time say 2 secs which would be enough for VB to detect that the keys have been pressed.

Also disabling Ctrl-Alt-Del through VB does not work because it is too fast for VB and I would like not to disable CTRL-ALT-DEL

Could some one please let me know how can a GINA stub be created ???

Upvotes: 1

Views: 3191

Answers (1)

Hans Olsson
Hans Olsson

Reputation: 55009

You can find an article about GINA here: Customizing GINA, Part 1

However, Windows Vista and up no longer uses GINA so you'd have to look at Credential Providers, but I'm not sure if they support what you want to do.

I'm not sure exactly what you need to do but I'd suggest that you might want to look at SystemEvents.SessionSwitch in case that might be useful (not used it myself but sounds like a possibility).

Upvotes: 2

Related Questions