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);

 

posted on 2012-09-25 11:15  空明流光  阅读(1104)  评论(0编辑  收藏  举报

导航