How to handle application termination via Task Manager(win32)

Started by
3 comments, last by Evil Steve 15 years, 2 months ago
Hey guys, I need a way to save the player profile on game exit(win32,c++). In some cases like killing the process from task manager I don't see any destroy messages sent to windows procedure function (looked with spy++). Is there a simple way to know when the game is being killed like with the task manager example? Thanks
Advertisement
When the taskmanager kills an application it calls TerminateProcess. The application must be killed without an option to catch this try. So in my opinion it is not possible to react for the application.
And that is definitly a good thing. If you have a buggy TerminateProcess-Handler you have to reboot the whole PC to kill the application. And that is just a friendly scenario :-).

With best regards,
Kimmi
A complicate solution may indicate a not understood problem.


[twitter]KimKulling[/twitter]
Those messages are only sent when you kill the application with Alt+F4 (or with another normal way to end an application).
There is a solution for .NET:
http://www.codeproject.com/KB/tips/CloseCheck.aspx

Still can't find an appropriate solutio for win32
Quote:Original post by vladic2000x
There is a solution for .NET:
http://www.codeproject.com/KB/tips/CloseCheck.aspx

Still can't find an appropriate solutio for win32
If you close the window from Taskmanager, then you get the WM_CLOSE notification. If you end the process from task manager, then there's no way to handle it, in .NET or Win32.

If there was a way to handle it, it'd be possible to make a process that can't be killed.

This topic is closed to new replies.

Advertisement