Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8029689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:30:32+00:00 2026-06-05T00:30:32+00:00

According to the WM_QUERYENDSESSION docs , Applications should respect the user’s intentions and return

  • 0

According to the WM_QUERYENDSESSION docs, “Applications should respect the user’s intentions and return TRUE.” This link summarized it as “[in XP] applications can return TRUE to indicate that they can be closed, or FALSE to indicate that they should not be closed”.

However, in my own app, it seems like the opposite is happening:

  • When I return FALSE, all the running apps get terminated and the computer restarts (and when my app gets the WM_ENDSESSION message, wParam is set to 1, indicating that “the system is shutting down or restarting” (see WM_ENDSESSION docs)).

  • When I return TRUE, some of the running apps get terminated, but when it gets to my app, it seems to halt the shut down process, and the subsequent WM_ENDSESSION message has wParam set to 0, as if the shut down was aborted, and my app remains open. Note also that since DefWindowProc “returns TRUE for [WM_QUERYENDSESSION]”, using that also blocks shutdown in the same manner.

If I completely remove all handling of WM_QUERYENDSESSION, then the whole shut down business goes through as normal, terminating my app and shutting down. This could indicate that there’s something just going terribly wrong in my app, since I assumed that that should result in the same behavior as using DefWindowProc. I have observed this behavior even if I pared down my handlers to ONLY be a return statement, either with TRUE or FALSE, or by passing the message and params on to DefWindowProc.

Since I don’t want to halt shut down, and was pretty much only handling it so I could log when it happens, I can just remove all handling of it and have things behave as desired. Of course, this doesn’t explain to me why this seems to be completely contradicting the docs, so I’m wondering if anyone has an ideas.

This is all going down in Windows XP, so the subsequent changes for Vista+ aren’t relevant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:30:34+00:00Added an answer on June 5, 2026 at 12:30 am

    Looks like I forgot a key bit of information about this: I was using dialog templates for my windows, so they were being handled with all the trappings of dialog boxes. As seen in the DialogProc docs, “If the dialog box procedure processes a message that requires a specific return value, the dialog box procedure should set the desired return value by calling SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult) immediately before returning TRUE.”

    The source of my issue could be explained with: “If the dialog box procedure returns FALSE, the dialog manager performs the default dialog operation in response to the message,” i.e., returning FALSE leads to the default behavior, which is to return TRUE and not block shutdown.

    It is also important to note, “Although the dialog box procedure is similar to a window procedure, it must not call the DefWindowProc function to process unwanted messages. Unwanted messages are processed internally by the dialog box window procedure.” So I was pretty much going about it all wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the docs: You should not override init. You are discouraged from overriding
According to JavaScript Patterns book (p. 79), this should work: var ob = {
According to an answer in this thread , semicolons are bad and should be
According to msdn, http://msdn.microsoft.com/en-us/library/bb774798%28VS.85%29.aspx , returning TRUE prevents user from editing labels. So I
According to the docs: http://msdn.microsoft.com/en-us/library/x13ttww7.aspx : The volatile keyword can be applied to reference
According to this SDK guide , unit-testing a Library project can be achieved by
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
According to connects documentation the session should expire when the browser is closed: By
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.