Macro definition wm_queryendsession

Source: Internet
Author: User

Because I am writing a small software. Some functions are not understood. I searched on the Internet for how to implement it. I found a lot. I feel like this blog post says: wm_queryendsession is quite good and I will repost it.

Mutual Learning: paste address T = 2441 & P = 1

Wm_queryendsession information is used to pass events that end a process or call the exitwindows function. that is to say, if the returned value of an event is 0, the process has not been terminated. when an event returns 0, only wm_queryendsession information is terminated.

After this information is processed, the system will pass the wm_endsession information with the wparam parameter (result of wm_queryendsession.

Then, use the windowproc function to obtain and receive the information:
Lresult callback windowproc (
Hwnd, // windows handle
Wm_queryendsession, // information to be passed
Wparam, // store useless information Parameters
Lparam // logout settings
Parameter information:
This parameter is only used to receive function information.
If this parameter contains endsession_logoff information, the user will be logged out. (Note: This parameter is a joke. only to test its value -- run with bit-wise; will not detect its results .)
If this parameter is set to 0, the system will be disabled.
Returned value
If you want a system event that can be easily shut down to get a response, it must return the true value. For other aspects, you must first return the false value.
In general, the defwindowproc function returns the true value information.

If an event returns the true value in this information, it receives the wm_endsession information and exits (that is, ends its own process), ignoring the execution of other events containing wm_queryendsession information.

In Windows ME/98/95, note that after all events return true values, all events will extract and end wm_endsession information.
Code Demonstration:
See the sample log off code.
System Requirements:
Client: Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows ME, Windows 98, or Windows 95.
Server: Windows Server 2003, Windows 2000 server, or Windows NT Server.
Header file: it has been declared in winuser. h; Include windows. h.
Related information (macro definition and function)
System shutdown overview, system shutdown messages, defwindowproc, exitwindows, wm_endsession

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.