Re-use parent console if it's available

* This means we won't get an ugly console window popping up when running
  renderdoccmd on windows, but if we run it from a terminal then we'll
  get output as normal.
* One downside is that cmd.exe seems to snoop the exe type (GUI or
  console) and if it's a GUI application it returns to the prompt
  immediately. bash for example though waits for process termination.
* The other is that pipe redirects to file don't work properly.
This commit is contained in:
baldurk
2017-08-28 15:47:57 +01:00
parent 24518e086c
commit d4488ff690
+9
View File
@@ -808,6 +808,15 @@ int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_
LPWSTR *wargv;
int argc;
if(AttachConsole(ATTACH_PARENT_PROCESS))
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
std::cout.sync_with_stdio();
std::cerr.sync_with_stdio();
}
wargv = CommandLineToArgvW(GetCommandLine(), &argc);
std::vector<std::string> argv;