Is there any event like in C# "FormClosing" but in C++ as Console closing where I can execute some code before the Console close? (In my case, I'd like to create a directory with the input of the user before the console is closed completely).
My guess is that you want to get the Event when clicking the [X]
BOOL WINAPI HandlerRoutine( DWORD eventCode )
{
switch( eventCode )
{
case CTRL_CLOSE_EVENT:
// do your thing
return FALSE;
break;
}
return TRUE;
}
Is that what you're looking for?
You also need to enable the Handler:
int main()
{
SetConsoleCtrlHandler( HandlerRoutine , TRUE );
getch();
}
More Info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With