C#编写的托盘程序 不关程序不关机的解决方法

来源:互联网 发布:淘宝的老七贸易靠谱么 编辑:程序博客网 时间:2024/05/21 06:16

private bool isExitApp = false;
        private const int WM_QUERYENDSESSION = 0x0011;
        protected override void WndProc(ref   Message m)
        {
            switch (m.Msg)
            {
                case WM_QUERYENDSESSION:
                    isExitApp = true;
                    break;
                default:
                    base.WndProc(ref   m);
                    break;
            }

        }
        private void Form7_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!this.isExitApp)
            {
                e.Cancel = true;
                this.WindowState = FormWindowState.Minimized;
                this.Hide();
            }

        }

原创粉丝点击