I want to hide my console of C when I run my application. How can I make my application run in the background?
-
My application contain many different processes which are for the full fulling the functionality of user. But the user only interact with main GUI, so that I want to hide all other processes. – Siddiqui Mar 11 '10 at 04:02
4 Answers
Programs with main()
by default are compiled as SUBSYSTEM:CONSOLE applications and get a console window. If you own the other processes your application is starting, you could modify them to be windowed applications by one of the following methods:
- Modify them to use
WinMain()
instead ofmain()
. This is the typical approach but requires modifying code. (If the reason for usingmain()
is for easy access toargc
/argv
, MSVC provides global__argc
/__argv
equivalents for windowed applications.) - Explicitly specifying the subsystem and entry point via
/SUBSYSTEM:WINDOWS /ENTRY:main
arguments tolink.exe
. - Use
editbin.exe
(from the Windows SDK) to change the subsystem type after the fact. This one might be useful if you don't have source code access to the spawned processes.

- 81,374
- 13
- 159
- 204
The easiest way to do this is to use a Windows Forms project rather than Console and then hide the startup form. The other option of course is a Windows Service, but this might be overkill ...

- 4,921
- 1
- 28
- 31
If I remember correctly, there's no way to do it programmatically. There are options to do it. I think I have done it in the past by creating a Windows project, but having no Windows Forms code (I am just including the files from my console application). No console window popped up. I believe I did it in Code::Blocks once by changing an option in the GUI. I am sorry I can't be specific, but I am using Visual Studio 2010 RC and the way I do it there may not be the same as yours.
Your comment makes me think that you're spawning processes. You do it by the function you call. I don't know what language you're using (I'll assume C, because you said you're launching a C application you created?), but there is either a flag to say hide the window or (or a flag you don't set to not show it) or use an alternative function which does the same thing, but launches the process a different way. Try shellexecute and system().

- 30,738
- 21
- 105
- 131