托盘程序的关机问题
由于改写了closing事件,使得关闭缩小到托盘中。然后用下面的函数来检测关机消息,系统关机或重启的时候,发现程序是关闭了,但是系统无法继续执行关机命令,请问问题出在那里?
protected override void WndProc(ref Message m)
{
//int WM_QUERYENDSESSION = 0x0011;
int WM_ENDSESSION = 0x0016;
if (m.Msg == WM_ENDSESSION )
{
m.WParam = (IntPtr)0;
m.Result = (IntPtr)1;
this.Close();
notifyIconServer.Visible = false ;
notifyIconServer.Dispose();
Application.Exit(); }
base.WndProc (ref m);
}