Click here to Skip to main content
15,891,597 members
Home / Discussions / C#
   

C#

 
GeneralRe: Check if a windows service is installed Pin
sludgenz29-Oct-08 16:22
sludgenz29-Oct-08 16:22 
GeneralRe: Check if a windows service is installed Pin
AnnDunbar19-Jan-09 4:55
AnnDunbar19-Jan-09 4:55 
GeneralTerminate C# app at system shutdown Pin
pahlsson15-Apr-03 22:19
pahlsson15-Apr-03 22:19 
GeneralRe: Terminate C# app at system shutdown Pin
perlmunger16-Apr-03 6:07
perlmunger16-Apr-03 6:07 
GeneralRe: Terminate C# app at system shutdown Pin
pahlsson16-Apr-03 6:10
pahlsson16-Apr-03 6:10 
GeneralRe: Terminate C# app at system shutdown Pin
perlmunger16-Apr-03 6:56
perlmunger16-Apr-03 6:56 
GeneralRe: Terminate C# app at system shutdown Pin
Jon Newman16-Apr-03 6:31
Jon Newman16-Apr-03 6:31 
GeneralRe: Terminate C# app at system shutdown Pin
James T. Johnson16-Apr-03 7:12
James T. Johnson16-Apr-03 7:12 
Somewhere on CP there is an article you can use in the Closing event to determine why you are being closed. Use that to handle the case where windows is shutting down to exit your program.

or

pahlsson wrote:
I know that WIndows sends the message WM_ENDSESSION

Your application is still running so it should still get the WM_ENDSESSION message. You'll need to lookup the real value of WM_ENDSESSION, then override WndProc to handle it.

protected override void WndProc(ref Message m)
{
  const int WM_ENDSESSION = 0x0016;
 
  switch(m.Msg)
  {
    case WM_ENDSESSION:
      bool sessionEnding = (bool) m.WParam;
 
      // process EndSession
      m.Result = 0;
      break;

    default:
      base.WndProc(ref m);
  }
}
However, MSDN says "The application need not call the DestroyWindow or PostQuitMessage function when the session is ending." so I don't think this is a suitable addition without my first suggestion implemented.

James

"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation

GeneralRe: Terminate C# app at system shutdown Pin
pahlsson16-Apr-03 7:17
pahlsson16-Apr-03 7:17 
GeneralRe: Terminate C# app at system shutdown Pin
pahlsson16-Apr-03 7:21
pahlsson16-Apr-03 7:21 
QuestionDirectory Dialog Box?? Pin
bania15-Apr-03 15:17
bania15-Apr-03 15:17 
AnswerRe: Directory Dialog Box?? Pin
Chris Austin15-Apr-03 18:54
Chris Austin15-Apr-03 18:54 
AnswerRe: Directory Dialog Box?? Pin
chito15-Apr-03 22:09
chito15-Apr-03 22:09 
AnswerRe: Directory Dialog Box?? Pin
Mazdak16-Apr-03 2:59
Mazdak16-Apr-03 2:59 
GeneralChange title bar color (or menu) Pin
mirano15-Apr-03 13:59
mirano15-Apr-03 13:59 
GeneralRe: Change title bar color (or menu) Pin
Chris Jobson15-Apr-03 23:06
Chris Jobson15-Apr-03 23:06 
GeneralRe: Change title bar color (or menu) Pin
mirano15-Apr-03 23:34
mirano15-Apr-03 23:34 
GeneralUnreachable Code Detected Pin
vinkoval15-Apr-03 12:43
vinkoval15-Apr-03 12:43 
GeneralRe: Unreachable Code Detected Pin
James T. Johnson15-Apr-03 13:27
James T. Johnson15-Apr-03 13:27 
GeneralRe: Unreachable Code Detected Pin
vinkoval15-Apr-03 18:52
vinkoval15-Apr-03 18:52 
GeneralRe: Unreachable Code Detected Pin
James T. Johnson15-Apr-03 19:01
James T. Johnson15-Apr-03 19:01 
GeneralSystem.Type usage Pin
S O S15-Apr-03 9:34
S O S15-Apr-03 9:34 
GeneralRe: System.Type usage Pin
Andres Manggini15-Apr-03 9:41
Andres Manggini15-Apr-03 9:41 
GeneralRe: System.Type usage Pin
S O S15-Apr-03 9:51
S O S15-Apr-03 9:51 
GeneralRe: System.Type usage Pin
James T. Johnson15-Apr-03 10:12
James T. Johnson15-Apr-03 10:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.