I am trying to open the console from my main program (Win32). I found some code, and it works, but I don\'t understand it. The problem I\'m happening is that when I click X
One thing you can do is disable the close button on the console window:
HWND hwnd = ::GetConsoleWindow(); if (hwnd != NULL) { HMENU hMenu = ::GetSystemMenu(hwnd, FALSE); if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); }