AFAIK, using the SessionEnded event is the "official" way to close down a
system tray application properly (e.g. see this example:
).
not use WM_QUERYENDSESSION. The only thing I did was to catch the
from the control menu. The system takes care of closing down my app when the
Regards, Jakob.
"Fuehner" wrote:
> Jakob--
>
> This url was of no help; I'm already overriding the WndProc as I showed from
> my code example...
>
> Other ideas..?
>
> "Jakob Christensen" wrote:
>
> > Have a look at SystemEvents.SessionEnded:
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfmicrosoftwin32systemeventsclasssessionendedtopic.asp
> >
> > HTH, Jakob.
> >
> > --
> >
http://www.dotninjas.dk > >
http://www.powerbytes.dk > >
> >
> > "Fuehner" wrote:
> >
> > > Thanks in advance...
> > >
> > > I have a windows forms c#.NET app that runs in the system tray; I'm
> > > experiencing intermitent problems with when the end-user goes to Log Off,
> > > Shutdown, etc...
> > >
> > > For the most part the app always closes on these events but, there are times
> > > when the user has to reselect the Log Off, Shutdown, etc button. It's almost
> > > as if their shutdown process was terminated...
> > >
> > > Again, this is an intermitent problem. Below is code I use in the
> > > application to determine when the users session is ending so that way I can
> > > close the app down...
> > >
> > > private int _wm_QueryEndSession = 0x11;
> > >
> > > protected override void WndProc(ref Message m)
> > > {
> > > try
> > > {
> > > if(m.Msg == this._wm_QueryEndSession)
> > > {
> > > Application.Exit();
> > > }
> > > base.WndProc(ref m);
> > >
> > > }
> > > catch(Exception ex)
> > > {
> > > Helper.writeEvent(ex,System.Diagnostics.EventLogEntryType.Error);
> > > }
> > > }
> > >
> > > Am I missing something or is there a sure fire way to kill the app and
> > > ensure the user is able to shutdown properly everytime..??
> > >