backspace
backspace

Reputation: 299

Visual c++ Hide Console Windows

I'm making an updater for my app. My app is a UI application. I want to make it as a console application but I don't know how to hide it. I used this code:

HWND hwnd = GetConsoleWindow();
ShowWindow(hwnd, 0);

But when application runs the cmd windows appears for a second. How can I hide it?

Upvotes: 0

Views: 2604

Answers (2)

user1520846
user1520846

Reputation: 69

FreeConsole() api will do that for you:

BOOL WINAPI FreeConsole(void);

Upvotes: 1

Cheers and hth. - Alf
Cheers and hth. - Alf

Reputation: 145419

What good is a console window that you proceed to hide (unless you're making a console window replacement, which you are not making)?

The easiest way to hide the console window is to not create it in the first place, i.e., simply don't link the exe as a console subsystem executable, but link at as a GUI (a.k.a. "windows") subsystem executable.

One consequence of that is that the standard Windows command interpreter won't wait for the program to finish, but that's all.


Another option is to run your program via a utility that starts it with the console window hidden. VBScript and Windows Script Host come to mind. But this would be a relatively speaking extreme complication in order to suppress a window that is only there because you've asked for it...

Upvotes: 0

Related Questions