• Welcome to Valhalla Legends Archive.
 

[C++] Running without a console

Started by CupHead, October 14, 2003, 09:02 AM

Previous topic - Next topic

CupHead

If I had a program that was designed to perform a specific task (i.e. Generate a massive text file) that I want to run background without a window being displayed, how would I go about doing so?

K

Assuming that you're dealing with windows, Compile under the windows subsystem instead of console so a console isn't automatically allocated for you.  Or perhaps something like:

#define _WIN32_WINNT 0x0500
#include <windows.h>

int main()
{
   // show output
   // ...
   ShowWindow(GetConsoleWindow(), SW_HIDE);
   // begin processing...
   // ...
   // finished, show results:
   ShowWindow(GetConsoleWindow(), SW_SHOW);

   return 0;
}