你说的不错,请仔细阅读以下内容,相信对你有所帮助.<br>以下来自Platform SDK<br>WM_QUERYENDSESSION<br>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. <br><br>After processing this message, the system sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message. <br><br>A window receives this message through its WindowProc function. <br><br>LRESULT CALLBACK WindowProc(<br> HWND hwnd, // handle to window<br> WM_QUERYENDSESSION, // the message to send<br> WPARAM wParam, // not used<br> LPARAM lParam // logoff option<br>);<br>Parameters<br>wParam <br>This parameter is reserved for future use. <br>lParam <br>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.) <br>Windows 2000/XP: If this parameter is zero, the system is shutting down. <br><br>Return Values<br>If an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE. <br><br>Remarks<br>By default, the DefWindowProc function returns TRUE for this message. <br><br>Windows NT/2000/XP: 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. <br><br>Windows 95/98/Me: After all applications return TRUE for this message, they receive the WM_ENDSESSION and they are terminated. <br><br>Requirements <br> Windows NT/2000/XP: Included in Windows NT 3.1 and later.<br> Windows 95/98/Me: Included in Windows 95 and later.<br> Header: Declared in Winuser.h; include Windows.h.<br><br>