C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-16-2008, 03:09 PM   #1
Beginning game programmer
 
Petike's Avatar
 
Join Date: Jan 2008
Posts: 62
Question Cleanup of the application...

Hi all,
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:
Code:
int main()
{
    initDirectX();

    .
    .   // Whatever code in application
    .

    cleanup();

    return 0;
}
But what if the program is NOT terminated normally?
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)
?
==================================================


Thanks.

Petike
Petike is offline   Reply With Quote
Old 08-16-2008, 05:23 PM   #2
The larch
 
Join Date: May 2006
Posts: 3,217
If I'm not mistaken, in case of Ctrl-Alt-Delete Windows will send your program a WM_CLOSE message or such, attempting to close the program in a usual way.

If your program is caught in an infinite loop or such this will not probably work. But if your program gets stuck in an infinite loop, unloading resources is not the biggest problem?
__________________
I might be wrong.

Quote:
Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Quoted more than 1000 times (I hope).
anon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
while statement wonderpoop C Programming 13 10-23-2006 09:14 PM
Problem with com application amardon C++ Programming 3 10-06-2005 05:50 AM
MFC run application by clicking on file... dug Windows Programming 4 12-02-2004 04:33 AM
Win application not very portable swed Windows Programming 5 10-01-2001 11:17 AM


All times are GMT -6. The time now is 08:06 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22