Windows 关闭取消 - 重新启动已关闭的应用程序
我有一个应用程序在收到关闭事件时停止,但该应用程序需要在用户会话中持续运行。如果有程序阻止关机,然后用户“取消”关机,则应用程序将不再运行。
有没有办法让Windows重新启动应用程序或让应用程序成为最后一个关闭的应用程序?
我已阅读: http://msdn.microsoft.com /en-us/library/ms686227%28VS.85%29.aspx 但这只会更改通知的顺序,并且在阻止关闭的应用程序终止后不会收到通知。
谢谢!
I have an application that stops when the shutdown event is received but this application needs to be continuously running in the user session. If there are programs preventing shutdown and then the user 'cancels' the shutdown the application is no longer running.
Is there a way to have windows restart the application or have the application be the very last application to shut down?
I have read: http://msdn.microsoft.com/en-us/library/ms686227%28VS.85%29.aspx but this only changes the order of the notification, and is not received after the applications preventing a shutdown are terminated.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将违反“如果两个程序执行此操作会怎样?< /a>”校长。
您是否使用过 SetProcessShutdownParameters() 来延迟应用程序关闭?这还不够吗?
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?
将 WM_ENDSESSION 添加到您的 Windows 消息处理中环形;仅当 Windows 实际上关闭时才会发送此消息。如果由于某种原因您的应用程序需要干预关闭过程,您还可以响应 WM_QUERYENDSESSION 消息。
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.