Hi list,
I am facing the problem that the system shutdown does not close my .net
application running in the system tray. After googeling around I implemented
this function:
protected override void WndProc(ref Message m)
{
// Exit message code.
int WM_QUERYENDSESSION = 0x11;
int WM_ENDSESSION = 0x16;
if (m.Msg == WM_QUERYENDSESSION || m.Msg == WM_ENDSESSION)
{
base.WndProc(ref m);
// Close application without prompting.
this.Close();
}
else
{
// Carry on with the message.
base.WndProc(ref m);
}
}
This code does close the .net application, however, system shutdown does not
continue. Why?
Another source (http://dotnet.org.za/ernst/archive/2004/01/28/236.aspx)
mentioned the use of subscribing to SystemEvents.SessionEnded. My problem
there is that I don't know how to get that working. Please help. Thanks a
lot! Dave.