如何知道用户执行了哪些操作,即关机、重启、待机、锁定或注销。我已经使用下面的代码来检查它,但我想识别每个案例并相应地执行操作。请建议一些方法来了解 Windows 窗体应用程序中的这些细节
private static int WM_QUERYENDSESSION = 0x11;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_QUERYENDSESSION)
{
MessageBox.Show(m.Msg.ToString() + " Endsession: this is a logoff, shutdown, or reboot");
systemShutdown = true;
}
// If this is WM_QUERYENDSESSION, the closing event should be
// raised in the base WndProc.
base.WndProc(ref m);
}