e.Cancel = true;加了这个以后注销不了。为难中。谁有好办法?

解决方案 »

  1.   

     private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
               if (!isExitApp)
               {
                    e.Cancel = true;
                   HideWindow();
                }
            }        #endregion        #region 隐藏窗口
            private void HideWindow()
            {
                this.WindowState = FormWindowState.Minimized;
                this.Hide();
                this.ShowInTaskbar = false;
                //this.notifyIcon1.Visible = true;
            }        #endregion
            #region 截获消息
            ///   
            /// 截获消息  
            ///   
            ///   
            protected override void WndProc(ref Message message)
            {
                switch (message.Msg)
                {
                    case WM_QUERYENDSESSION:
                        isExitApp = true;
                        break;
                }
                base.WndProc(ref message);
            }
            #endregion