李颖:
windows关机之前会给每一个App发消息,询问是否可以关机
[阅读: 579] 2004-09-17 03:56:14
如果App拒绝,那就不关
The ExitWindows function logs off the current user. All applications must agree to terminate before the user logs off. If any application returns FALSE when it processes the WM_QUERYENDSESSION message, the user is not logged off. If your application handles the WM_QUERYENDSESSION message, you can allow the user to cancel the log-off operation, even if another application or Windows originated the end-session request.
The following example logs off the current user, unless the user clicks the No button in the message box displayed when the application receives the WM_QUERYENDSESSION message.
// Log off the current user.
ExitWindows(0, 0);
// Process the message in the application's window procedure.
case WM_QUERYENDSESSION:
{
int r;
r = MessageBox(NULL, "Shut down?","WM_QUERYENDSESSION", MB_YESNO);
// Return TRUE to allow shutdown, FALSE to stop.
return r == IDYES;
break;
}
-
DISSENT IS THE HIGHEST FORM OF PATRIOTISM !
--Thomas Jefferson
DISSENT IS THE HIGHEST FORM OF PATRIOTISM !
--Thomas Jefferson