Автор вопроса: Barsik | Web-сайт:barsik.newmail.ru | ICQ: 343368641
Вопрос в следующем...
Как отловить сообщения Виндовоза типа выкл.компа(перезагр, логофф)..
Так же как отложить или прервать выкл.компа(перезагр, логофф)..
Спасибо за ответы...
WM_QUERYENDSESSION
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
WM_QUERYENDSESSION, // the message to send
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
Parameters
wParam
This parameter is reserved for future use.
lParam
Specifies whether the user is logging off or shutting down the system. If this parameter includes the ENDSESSION_LOGOFF value, the user if 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.)
Windows 2000/XP: If this parameter is zero, the system is shutting down.
Return Values
If an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE.
WM_ENDSESSION
The WM_ENDSESSION message is sent to an application after the system processes the results of the WM_QUERYENDSESSION message. The WM_ENDSESSION message informs the application whether the session is ending.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
WM_ENDSESSION, // the message to send
WPARAM wParam, // end-session option
LPARAM lParam // logoff option
);
Parameters
wParam
Specifies whether the session is being ended. If the session is being ended, this parameter is TRUE; otherwise, it is FALSE.
lParam
Specifies whether the user is logging off or shutting down the system. If this parameter includes the ENDSESSION_LOGOFF value, the user if 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.)
Windows 2000/XP: If this parameter is zero, the system is shutting down.
Return Values
If an application processes this message, it should return zero.
Remarks
If the wParam parameter is TRUE, the session can end any time after all applications have returned from processing this message. Therefore, an application should perform all tasks required for termination before returning from this message.