Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC / C how to hide console window?

Tags:

People also ask

How do I hide the console in Windows?

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

How do I hide the console window in python?

“python hide console” Code Answer's Simply save it with a . pyw extension. This will prevent the console window from opening.


****C newbie alert**** How do I compile a C app so that it runs without showing a console window on Windows? I'm using Windows XP and GCC 3.4.5 (mingw-vista special r3). I've googled this exhaustively and I've come up with the following which, according to what I've read, sounds like it's supposed to do the trick, but doesn't on my system:

#include <windows.h>
#include <stdlib.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    system("start notepad.exe");
}

I've also tried passing the "-mwindows" argument to GCC to no avail. The code sample launches Notepad but still flashes up a command prompt.

EDIT: FWIW I have also tried ShellExecute as an alernative to system(), although I would be happy to even get an app with an empty main() or WinMain() working at this point.