From 4c900be00a60ab3914e07e5236b393e8e4b762bc Mon Sep 17 00:00:00 2001 From: Timur Doumler Date: Wed, 4 May 2016 18:40:41 +0100 Subject: [PATCH] Added some init code to enable stdout, stderr, stdin in the special case that we run an non-console Windows app inside a Windows console such as cmd.exe or PowerShell. --- modules/juce_events/messages/juce_ApplicationBase.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/juce_events/messages/juce_ApplicationBase.cpp b/modules/juce_events/messages/juce_ApplicationBase.cpp index 66cd07f4b6..f130bf4199 100644 --- a/modules/juce_events/messages/juce_ApplicationBase.cpp +++ b/modules/juce_events/messages/juce_ApplicationBase.cpp @@ -257,6 +257,16 @@ bool JUCEApplicationBase::initialiseApp() } #endif + #if JUCE_WINDOWS && JUCE_STANDALONE_APPLICATION && ! defined (_CONSOLE) + if (AttachConsole (ATTACH_PARENT_PROCESS) != 0) + { + // if we've launched a GUI app from cmd.exe or PowerShell, we need this to enable printf etc. + freopen("CON", "w", stdout); + freopen("CON", "w", stderr); + freopen("CON", "r", stdin); + } + #endif + // let the app do its setting-up.. initialise (getCommandLineParameters());