本文介绍了如何检测工作站锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发应用程序,并且试图检测工作站何时被锁定,例如通过用户按下Windows + L键.
I'm developing an application and I'm trying to detect when the workstation gets locked, for example by the user pressing the Windows + L keys.
我知道lock事件具有值
I know that the lock event has the value
WTS_SESSION_LOCK 0x7但是我不知道如何使用它.我已经在网上搜索了,但一无所获.
But i don't know how to use it. I've searched the web but found nothing.
推荐答案最终在VB上成功做到了:D
Finnallly managed to do it on VB :D
首先,您需要导入库:
Imports System Imports Microsoft.Win32 Imports System.Windows.Forms然后添加处理程序:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load AddHandler SystemEvents.SessionSwitch, AddressOf SessionSwitch_Event End Sub最后,创建捕获它的子项:
Finnally you create the sub that captures it:
Private Sub SessionSwitch_Event(ByVal sender As Object, ByVal e As SessionSwitchEventArgs) If e.Reason = SessionSwitchReason.SessionLock Then MsgBox("Locked") End If If e.Reason = SessionSwitchReason.SessionUnlock Then MsgBox("Unlocked") End If End Sub最后一次删除处理程序:
Last you remove the handler:
Private Sub closing_event(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing RemoveHandler SystemEvents.SessionSwitch, AddressOf SessionSwitch_Event End Sub更多推荐
如何检测工作站锁
发布评论