2

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.

Community
  • 1
  • 1
mic_e
  • 5,594
  • 4
  • 34
  • 49
  • 3
    Maybe, [this](http://stackoverflow.com/q/54536/2861476) could help you. – MC ND Sep 23 '16 at 06:27
  • 3
    Use `/SUBSYSTEM:WINDOWS` and [AttachConsole](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681952.aspx) to determine, whether you should [AllocConsole](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681944.aspx) a new console window, or re-use the parent process' console. – IInspectable Sep 23 '16 at 09:06

0 Answers0