On the different platforms, this is where an application's stdout
will appear (I have marked the parts that I'm unhappy with):
If started from within a console window
- Linux: In the console window
- win32 "WinMain": Nowhere
- win32 "main": In the console window
If started by double-click on the desktop icon
- Linux: Nowhere
- win32 "WinMain": Nowhere
- win32 "main": A new console window is opened just for the application
I'm trying to build a mixed-mode application. Depending on the command-line arguments, it shall either open a GUI, or behave as a command-line application. This works fine on Linux, but on win32, I have to decide whether to make the whole thing "WinMain" or "main". No matter which I choose, one of the two modes is broken.
I have figured a way to hide a main
application's console window, but this solution is less than ideal (if launched from an existing console, that console is hidden; if launched from a new console, that console flashes up before being hidden).
Is there a set of win32 API calls that will make either "main" or "WinMain" mode behave the way that applications behave on Linux?
Note that I also need to be able to process the application's stdout (if launched in command line application node through CreateProcess
/CreatePipe
as described here.
The language is python3
, but I believe this hardly matters.