The OS doesn't shutdown, but my application does
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
Do you indeed return TRUE to the WM_QUERYENDSESSION (or similar) OS messages? You might get the message, close the app and return FALSE.
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.
- Removing a datamodule fixed the problem.
- Removing the NMsmtp component fixed the problem.
- Implementing the suggestion given in this bug report fixed the problem on my workstation, but not on another.
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.
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
精彩评论