Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 programming hiding console window

Tags:

I'm learning C++ and I made a new program. I deleted some of my code and now my console window is not hidden. Is there a way to make it hide on startup without them seeing it?

like image 229
H4cKL0rD Avatar asked Mar 07 '09 22:03

H4cKL0rD


People also ask

How do you hide a console window?

"SW_HIDE" hides the window, while "SW_SHOW" shows the window.


1 Answers

If you're writing a console program and you want to disconnect your program from the console it started with, then call FreeConsole. Ultimately, you probably won't be satisfied with what that function really does, but that's the literal answer to the question you asked.

If you're writing a program that you never want to have a console in the first place, then configure your project so that it is not a console program. "Consoleness" is a property of the EXE file. The OS reads that setting and decides whether to allocate a console for your program before any of your code ever runs, so you can't control it within the program. Sometimes a non-console program is called a "GUI program," so you might look for a choice between "console" and "GUI" in the configuration options of your development environment. Setting it to GUI doesn't require that you have any user interface at all, though. The setting merely controls whether your program starts with a console.

If you're trying to write a program that can sometimes have a console and sometimes not, then please see an earlier question, Can one executable be both a console and GUI app?

like image 109
Rob Kennedy Avatar answered Sep 21 '22 06:09

Rob Kennedy