gpt4 book ai didi

vb.net - 计算机关闭事件 ?网络

转载 作者:行者123 更新时间:2023-12-02 04:28:56 25 4
gpt4 key购买 nike

Possible Duplicate:
Detecting windows shutdown event

VB.NET 中是否有有关关闭的事件?我想在用户点击关闭计算机时执行语句,这可以在vb.net中完成吗?

最佳答案

示例来自 here

Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
AddHandler Microsoft.Win32.SystemEvents.SessionEnding, _
AddressOf Handler_SessionEnding
End Sub

Public Sub Handler_SessionEnding(ByVal sender As Object, _
ByVal e As Microsoft.Win32.SessionEndingEventArgs)
If e.Reason = Microsoft.Win32.SessionEndReasons.Logoff Then
MessageBox.Show("User is logging off")
ElseIf e.Reason = Microsoft.Win32.SessionEndReasons.SystemShutdown Then
MessageBox.Show("System is shutting down")
End If
End Sub
End Class

关于vb.net - 计算机关闭事件 ?网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14376605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com