
Envoyé par
'msdn
The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls the ExitWindows function. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero.
After processing this message, the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
Parameters
hwnd
Handle to window.
uMsg
WM_QUERYENDSESSION identifier.
wParam
This parameter is reserved for future use.
lParam
If this parameter includes ENDSESSION_LOGOFF, the user is logging off. (Note that this parameter is a bit mask. To test for this value, use a bit-wise operation; do not test for equality.)
If this parameter is zero, the system is shutting down or restarting (it is not possible to determine which event is occurring).
Return Values
If an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE.
Remarks
By default, the DefWindowProc function returns TRUE for this message.
If your application receives a shutdown notification while it is in the middle of an operation that should not be aborted, such as burning media or making a backup, it should display a dialog box. Warn the user what might happen if the operation is interrupted and enable the user to choose whether to cancel or continue the shutdown. If the user would like to cancel the shutdown, the application should return FALSE for this message.
When an application returns TRUE for this message, it receives the WM_ENDSESSION message and it is terminated, regardless of how the other applications respond to the WM_QUERYENDSESSION message.
Windows Me/98/95: After all applications return TRUE for this message, they receive the WM_ENDSESSION and they are terminated.
Partager