In C++, what is the standard way to remove the command prompt, without using WinMain()? This is hopefully a simple question. I am using MSVC.
Asked
Active
Viewed 989 times
2
-
Do you mean the whole console window? If so, that the way. – kenny Sep 25 '10 at 12:38
-
If by standard your mean in the C++ standard, theres no "standard way" – alternative Sep 25 '10 at 12:38
-
similar question: http://stackoverflow.com/questions/2139637/hide-console-of-windows-application note there are methods to dynamically remove the console window – dyp Sep 25 '10 at 12:45
1 Answers
7
First you need to set /SUBSYSTEM:WINDOWS
(as opposed to /SUBSYSTEM:CONSOLE
), you can do this in GUI (right click the project, properties, Linker, System, Subsystem).
Then you have to either
- define
WinMain
, or - define
main
and set the entry point tomainCRTStartup
(properties, Linker, Advanced, entry point).

avakar
- 32,009
- 9
- 68
- 103
-
Good, it worked. Is there a solution that will not require me to change any project settings. Like a preprocessor or macro, ect... – Alexander Rafferty Sep 25 '10 at 13:15
-
using `#pragma comment(linker, "/SUBSYSTEM:WINDOWS")` you could do the same for the other options. Check the `pragma` preprocessor. – st0le Sep 25 '10 at 13:18