2

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.

Alexander Rafferty
  • 6,134
  • 4
  • 33
  • 55
  • 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 Answers1

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

  1. define WinMain, or
  2. define main and set the entry point to mainCRTStartup (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