如何检测工作站锁

编程入门 行业动态 更新时间:2024-10-24 06:31:21
本文介绍了如何检测工作站锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发应用程序,并且试图检测工作站何时被锁定,例如通过用户按下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

更多推荐

如何检测工作站锁

本文发布于:2023-11-05 04:55:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559959.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作站

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!