C# 关机消息拦截的几种方法:
Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);
protected override void WndProc(ref Message m) { const int WM_QUERYENDSESSION = 0x011; const int WM_ENDSESSION = 0x16; if (m.Msg == WM_QUERYENDSESSION) { } else if (m.Msg == WM_ENDSESSION) { } base.WndProc(ref m); }
this.FormClosing += new FormClosingEventHandler(frmMain_FormClosing);
桂棹兮兰桨,击空明兮溯流光。