I am currently learning graphics programming in DirectX (but I want to talk about my problem in general way, so I will not bother you with DirectX details).
So let's say that we must first initialize the DirectX before using it and in the end of the application we must clean it up. So when the program runs normally and nothing obvious happens, the cleanup at the end of the program will run normally and the application will end. So everything is all right, yeah.
Here is the sample:
But what if the program is NOT terminated normally?
. // Whatever code in application
For example what when the user press "CTRL+ALT+DEL" in the middle of the program and terminate the program himself? -> the cleanup will be NEVER achieved.
So HERE IS MY QUESTION:
Is there any way to perform the cleanup of the application although
the user terminates the application with "CTRL+ALT+DEL" (or where
should I put my "cleanup()" function in the code)?