Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run C program in background without command window flashing

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a C program executable and I want to run in the bakcground. It had no "printf" commands. But still everytime I run it, it outputs a commmand windows. Is there a way to run the program quietly in the background with the command windows flashing even if only for a brief.

Thank you.
 
If it is Windows, change void or int main ( int argc, char * argv[] ) to:
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)

Note that you get the original command-line without the program name, not an argv array. If you also need the program name, call the API GetCommandLine ( )
Marcel
 
What about if it is NOT an windows. My code will be run in windows but it doesn't uses handles and winmain.
 
That doesn't matter at all.

If you have a main entrypoint, a program is considered to be a console program and therefore needs a console, even if it is not used.
If you have a WinMain entry point, a program is considered to be a GUI program, but no windows are actually created for it, it is assumed to do it yourself. But, you don't have to, if you don't the program runs completely silent.

By the way, it might be you need to change a flag (if you are compiling and linking from the IDE) to tell the linker it is now a GUI and not a console program.
Marcel
 
It maynot make sense but ..... I am not using Visual C++ to compile .... I just have a Unix-type C Program .... with main and a bunch of function calls.

How can I change it so that the console won't appear?

Example program:

# include ....
void main()
{
// my code
}

In that program above, what do I need to add to make-believe it as a GUI ..... Thanx for the help .....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top