1

我有一个应用程序在收到关闭事件时停止,但该应用程序需要在用户会话中持续运行。如果有程序阻止关机,然后用户“取消”关机,则应用程序不再运行。

有没有办法让 Windows 重新启动应用程序或让应用程序成为最后一个关闭的应用程序?

我已阅读: http: //msdn.microsoft.com/en-us/library/ms686227%28VS.85%29.aspx但这只会更改通知的顺序,并且在阻止关机的应用程序之后不会收到终止。

谢谢!

4

2 回答 2

2

Is there a way to have windows restart the application or have the application be the very last application to shut down?

This would violate the "What if two programs did this?" principal.

Have you used SetProcessShutdownParameters() to delay your apps shut down? Is that not enough?

于 2011-04-04T23:17:09.310 回答
1

Add WM_ENDSESSION to your Windows message handling loop; this is only sent when Windows is in fact shutting down. If for some reason your app needs to intervene in the shutting down process, you can also respond to the WM_QUERYENDSESSION message.

于 2011-04-04T23:29:01.997 回答