This article has been published by the author Wang Rongtao authorized NetEase Cloud community.
Welcome to NetEase Cloud Community, learn more about NetEase Technology product operation experience.
First of all XP systems and Vista later systems, these two messages are handled differently.
XP system
The system sends Wm_queryendsession, if you return false, in most cases, the system's logoff operation is terminated, and the next received Wm_endsession's wparam parameter value is false. In accordance with Microsoft's application design guidelines, this time you need to give the UI to tell the user why it was terminated.
The application can temporarily not respond to this message, such as not returning, but in the process of handling the message the code pops a modal dialog box prompts the user to choose.
By default, you have 5 seconds to deal with this thing. More than 5 seconds after the system has a dialog box indicating that the application is unresponsive.
If any top-level window returns FASLE when processing Wm_queryendsession, the logoff process is canceled, and the window that receives the message receives a wm_endsession message, and its wparam will be false.
Only if all top-level windows return true after they receive wm_queryendsession, they are sent wm_endsession at once and the wparam message is true. Once you enter this step, the logoff process cannot be undone.
Processing Wm_endsession time is also 5 seconds, more than after the system will also pop the window prompt. Once the application responds to the Wm_endsession message, Windows closes it. Next, Windows will continue to send wm_endsession to the rest of the application one by one.
Vista after system
Compared to the XP system, the Vista system has been modified in the following ways:
UI improvements that do not respond to application hints
Allow forced shutdown
Unable to silently revoke the logoff process (Wm_queryendsession returns false)
Providing an API to block shutdown, not using these APIs and returning false only to wm_queryendsession is not possible
Certain types of applications (such as console programs and programs with no visible top-level windows) will no longer be allowed to block shutdown, and programs that do not respond to any messages within 5 seconds will be terminated during shutdown
Default timeout value modification (mostly reduced)
Best practices for system processing shutdown after Vista
Try not to stop the shutdown so that the user experience is the best
Apps that must be blocked from shutting down must use the new API:
Before the system shuts down, the application that needs to block the shutdown needs to call Shutdownblockreasoncreate () before the critical code, call Shutdownblockreasondestroy () after the code, and if you receive WM_ Queryendsession when the operation has not completed, then return false
When you receive wm_queryendsession, do you know if you want to block the shutdown application needs to call Shutdownblockreasoncreate () and return false in the handler function of the message. Then call Shutdownblockreasondestroy () after the critical work is complete
Applications that do not have a visible top-level window need to call Shutdownblockreasoncreate () and then return True when they receive wm_queryendsession when they use more than 30 seconds to process wm_endsession.
NetEase Cloud Free Experience Pavilion, 0 cost experience 20+ Cloud products!
More NetEase technology, products, operating experience sharing please click.
Related articles:
"Recommended" "RABBITMQ Learning Record"-Message Queuing storage mechanism source code Analysis
A preliminary study on the "recommended" puppeteer
Wm_queryendsession and Wm_endsession