Thread: Need help with WM_QUERYENDSESSION message

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Need help with WM_QUERYENDSESSION message

    I know that when I try to shutdown the OS, it sends the WM_QUERYENDSESSION message... and I need to return TRUE when the OS does that.

    like:
    Code:
    case WM_QUERYENDSESSION:
                  return(TRUE);


    But the question is, if I want to make savings when the OS is shuting down, I will do it at the WM_QUERYENDSESSION message, or the WM_ENDSESSION message?


    Thanks
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Basically, if you want to save before the program ends, you need only process the WM_CLOSE and WM_QUERYENDSESSION messages.

    The WM_ENDSESSION message is sent to every wndproc that has already received a WM_QUERYENDSESSION. It is used so that the application can tell if it still has to terminate. Because it is possible for someone to ask to shut down Windows, and a program repsonds to WM_QUERYENDSESSION with 'no, i dont want to shut down' (perhaps at the response of a user clicking 'cancel' to the save dialog). This means Windows is now not shutting down. WM_ENDSESSION answers the question of whether it is going to shut down or not. This happens when another program returned 0 from WM_QUERYENDSESSION indicating that it is not shutting down. wParam will be 0 for WM_ENDSESSION, if this happens.

    That's the basics of it, you may wish to read up on MSDN for further information.

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    Thanks alot
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM