Last active
December 25, 2021 23:22
-
-
Save opsJson/b0266efba72986dc0fcbf67e694daf75 to your computer and use it in GitHub Desktop.
Re-enable console for win32 apps, or hide console for console apps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <windows.h> | |
| char SHOW_FLAG = 0; | |
| void console_show() { | |
| AllocConsole(); | |
| freopen("CONIN$", "r", stdin); | |
| freopen("CONOUT$", "w", stdout); | |
| freopen("CONOUT$", "w", stderr); | |
| SHOW_FLAG = 1; | |
| } | |
| void console_hide() { | |
| HWND window; | |
| AllocConsole(); | |
| window = FindWindow("ConsoleWindowClass", NULL); | |
| if (window) ShowWindow(window, 0); | |
| } | |
| /*/////////////////////////////////// | |
| Testing: | |
| ///////////////////////////////////*/ | |
| int main() { | |
| console_show(); | |
| printf("foo!\n"); | |
| system("pause"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment