I´m making a program that must save its files without user interaction when the computer is being turned off.  I tried, but I cannot understand how to do it, because most of the info I found is for C#.  I found the SystemEvents::SessionEnding event using the below code for C++, but I don´t know how to implement this in dev-c++:
public:
    event SessionEndingEventHandler^ SessionEnding {
        static void add(SessionEndingEventHandler^ value);
        static void remove(SessionEndingEventHandler^ value);
    }
}