Possible duplicate:
Can one executable be a console and a graphical interface?
I am writing a C # program that, by default, works as a standard Windows application (Project Properties → Output Type).
Its normal behavior is that it starts from a shortcut or something else and displays a graphical interface.
However, with some command line arguments, it will run as a console application, not display the GUI, and return the exit code to the calling shell.
I was misled in the fact that if I compile it as a “Windows application” when it launches its plugs, and the parent thread immediately returns to the calling process, and the program is still running in an independent child thread. This means that it cannot return the exit code to the calling process when it exits, because it already happened when the program was started and forked. As for the calling process, the application always exits immediately and returns zero.
For a direct console program, the answer is simple - compile it as a "console application". In this case, the application does not start at startup, and the call process waits for the program to complete and returns an exit code. Unfortunately, going down this route, Windows always displays a command window (the console, whatever you call ... a big black thing!), Which is unpleasant if the program runs in graphical mode. I guess I could call an API call to hide this window, but it will still flash instantly.
So, is there a way to stop the “Windows application” from being deployed when it starts? Or, alternatively, is there a way to control whether the console application displays a console window? Ideally, this would be C # code, allowing me to choose what happens based on command line arguments.
, , ( forking).
Cocoa (Mac) ( , ). , Windows . !: -)
.