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 http://www.zhuoda.org/bbs/getMsgs.jsp? 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:
Wparam
This parameter is only used to receive function information.
Lparam
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.
------------------------------------------------
Note:
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.
Http://msdn.microsoft.com/library/en-us/sysinfo/base/logging_off.asp)
------------------------------------------------
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