操作系统没有关闭,但我的应用程序却关闭了
我有一个应用程序,当我关闭 Windows 时,它会优雅且快速地退出(也在任务管理器和进程资源管理器中检查 - 该进程不再存在),但操作系统却没有。看来操作系统只是忽略了关机。
但如果我尝试再次关闭 Windows,现在一切正常。系统以非常正常的方式关闭。
- 为什么?
- 我该如何解决这个问题?
关于我的应用程序的详细信息:
- 多线程
- 有一个托盘图标
- 不对WM_QUERYENDSESSION(或类似)消息进行任何特殊处理操作系统消息
- 没有任何特殊驱动程序,DLL钩子等。
任何想法如何修复它?
PS:我可以根据您的要求提供更多详细信息
I have an application which when I close the Windows, it exits gracefully and quickly (checked also in Task Manager and Process Explorer - the process isn't there anymore) but the OS doesn't. It seems that OS just ignores the Shutdown.
But if I try to close once more the Windows, now everything is ok. The system shuts down in a very normal way.
- Why?
- How can I fix this?
Details about my app:
- multithreaded
- has a tray icon
- doesn't do any special processing of WM_QUERYENDSESSION (or similar) OS messages
- doesn't have any special driver, DLL hook etc.
Any ideas how to fix it?
PS: I'm at your disposition with and further details upon request
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您确实对 WM_QUERYENDSESSION (或类似)操作系统消息返回 TRUE 吗?您可能会收到该消息,关闭应用程序并返回 FALSE。
Do you indeed return TRUE to the WM_QUERYENDSESSION (or similar) OS messages? You might get the message, close the app and return FALSE.
奇怪但几乎完全相同的问题本周困扰着我们。
该应用程序在托盘中运行,关闭但阻止窗口关闭。因此,到了那里后,我将分享为我们解决问题的方法。
最后,我们选择删除没有源代码的 NMsmtp 组件,改用 Indy。
最有可能的是,您的情况会有所不同,因此我建议您像我们一样,开始从项目中剥离所有内容,直到它起作用为止。
Strange but almost exactly the same problem bugged us this week.
The application ran in the tray, closed but prevented windows from shutting down. So having been there, I'll share what fixed the problem for us.
In the end, we choose to just remove the NMsmtp component for wich we didn't have the source code and changed to using Indy.
Most likely, your situation will differ therefore I'd suggest you do like we did and start stripping everything from you project until it works.
如果应用程序仍在后台运行,这可能会阻止 Windows 关闭。
您可以检查 AutoEndTasks 设置是否已启用,如果没有启用它:
http:// /technet.microsoft.com/en-us/library/cc978604.aspx
最好的问候
If the application still doing work on the background this could be prevent Windows to shutdown.
You could check if the AutoEndTasks settings are enabled and enabled it if not :
http://technet.microsoft.com/en-us/library/cc978604.aspx
Best Regards