Start console app in background?

I've used ShowWindow() with SW_HIDE to hide my console program, but a visible window briefly pops up when the program first starts. I've tried configuring /SUBSYSTEM:WINDOWS and /ENTRY:mainCRTStartup (actually makes the console window hang for much longer).. also tried using WinMain() instead of main(). I'm not interested in making the process run as system or ring0.

I can do this with DirectX but most def don't want to go that route with this program. Is there any way around this pointless window popping up at startup?
I'm using VC++ 2010.
Setting the window position before hiding it seems to make the console disappear almost instantly, but it might still show up if its being slow.

1
2
3
4
5
int main() {
	SetWindowPos(GetConsoleWindow(), NULL, 5000, 5000, 0, 0, 0);
	ShowWindow(GetConsoleWindow(), SW_HIDE);

}
IMO if you want to let the program hides itself, it shouldn't be a console program. I'd start with a Win32 program.

I created a Win32 program (the entry point is WinMain), and it works perfectly for me.

Please make sure your program didn't allocate a console manually.
subsystem windows entry point maincrtstartup winmain , yes yes. It wont create a console thought but you can allocate it at runtime and hide it like Bingocat4 shown you. Or simply use a file for you outputs.
Topic archived. No new replies allowed.