我一直在这个问题上有点难过。我需要检测用户何时登录、显示器何时锁定以及用户何时注销。过去,我使用过一个 VB.NET 应用程序,它使用对 Sens(系统事件通知服务)的 COM 引用,该引用利用了 Sens Events ISensLogon 接口。
但是,自从迁移到 Windows 10 后,我不再能够将 Sens 作为 COM 对象添加到我的项目中。为了使用此功能,我是否缺少 SDK?
我需要使用另一个 COM 库或参考来检测 Windows 10 中的这些事件吗?
我一直在这个问题上有点难过。我需要检测用户何时登录、显示器何时锁定以及用户何时注销。过去,我使用过一个 VB.NET 应用程序,它使用对 Sens(系统事件通知服务)的 COM 引用,该引用利用了 Sens Events ISensLogon 接口。
但是,自从迁移到 Windows 10 后,我不再能够将 Sens 作为 COM 对象添加到我的项目中。为了使用此功能,我是否缺少 SDK?
我需要使用另一个 COM 库或参考来检测 Windows 10 中的这些事件吗?
尝试这个:
Imports Microsoft.Win32
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddHandler SystemEvents.SessionSwitch, AddressOf SystemEvents_SessionSwitch
End Sub
Private Sub SystemEvents_SessionSwitch(sender As Object, e As SessionSwitchEventArgs)
Select Case e.Reason
Case SessionSwitchReason.SessionLock
MessageBox.Show("Lock")
Case SessionSwitchReason.SessionLogoff
MessageBox.Show("LogOff")
Case SessionSwitchReason.SessionLogon
MessageBox.Show("Login")
Case SessionSwitchReason.SessionUnlock
MessageBox.Show("Unlock")
Case Else
End Select
End Sub
End Class
尝试在 .NET 框架使之成为可能的时间和地点远离 COM。