日期:2014-05-19  浏览次数:20721 次

关机时托盘程序不能退出
C#的windows托盘程序,关机或重新启动时,必须要手动结束托盘程序.否则,永远无法关机.谁有好的解决办法?

------解决方案--------------------
这样的软件你自己会用吗?
ps:要是电源/硬件故障又如何?双机热备?
------解决方案--------------------
解决关机问题
在mainForm中重写WndProc:
const int WM_QUERYENDSESSION = 0x0011;
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{

case WM_QUERYENDSESSION:
this.Close();
this.Dispose();
Application.Exit();

m.Result = (IntPtr)0;
break;
default:
break;
}
base.WndProc(ref m);
}