Cleanup of the application...

This is a discussion on Cleanup of the application... within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, I am currently learning graphics programming in DirectX (but I want to talk about my problem in general ...

  1. #1
    Beginning game programmer Petike's Avatar
    Join Date
    Jan 2008
    Posts
    64

    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

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    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.

    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).

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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