中国开发网: 论坛: 程序员情感CBD: 贴子 24475
李颖: windows关机之前会给每一个App发消息,询问是否可以关机
如果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

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录