Change renderdoccmd to be a console program on windows.

* This means it outputs natively/properly to stdout/stderr and its output can be
  redirected with pipes.
* It does mean we need to be very careful whenever it's run internally to not
  pop up a command window, which happens by default.
This commit is contained in:
baldurk
2019-01-09 16:27:15 +00:00
parent 150e6527ad
commit d265a14a45
10 changed files with 44 additions and 38 deletions
+3 -18
View File
@@ -752,21 +752,12 @@ std::string getParentExe()
return "";
}
int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine,
_In_ int nShowCmd)
// ignore the argc/argv we get here, convert from wide to be sure we're unicode safe.
int main(int, char *)
{
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;
@@ -789,13 +780,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInst, _In_opt_ HINSTANCE hPrevInstance, _In_
parent[i] = '/';
}
if(strstr(parent.c_str(), "/cmd.exe") && AttachConsole(ATTACH_PARENT_PROCESS))
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
hInstance = hInst;
hInstance = GetModuleHandleA(NULL);
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);