exit event x button

how am i to save a list class using this isee no way to pass the class object or make the handler a member of the class i also can seem to find where the handler returns to also dtors dont hit on x button exits

BOOL WINAPI ConsoleHandler(DWORD CEvent)

ofstream o;

cout<<"program exit detected ";

//save list
//class object

return 1;

void main()

//list l;
if (SetConsoleCtrlHandler( (PHANDLER_ROUTINE)ConsoleHandler,TRUE)==FALSE)
// unable to install handler...
// display message to the user
printf("Unable to install handler!\n")


//click x button
Last edited on
Sorry that I am a bit late in seeing this. You are already setting the Callback with the "SetConsoleCtrlHandler()" function and passing it a pointer to the function you wrote. This basically makes your function a member of the class for the console window. This function won't return to your program, it's for handling Windows Messages that are sent to the console.
Topic archived. No new replies allowed.