mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-14 21:32:27 +00:00
Attach to the parent console to print list output on Win32
This commit is contained in:
parent
ecddada150
commit
3e330b7929
1 changed files with 16 additions and 0 deletions
16
app/main.cpp
16
app/main.cpp
|
@ -492,6 +492,22 @@ int main(int argc, char *argv[])
|
||||||
#ifdef USE_CUSTOM_LOGGER
|
#ifdef USE_CUSTOM_LOGGER
|
||||||
// Don't log to the console since it will jumble the command output
|
// Don't log to the console since it will jumble the command output
|
||||||
s_SuppressVerboseOutput = true;
|
s_SuppressVerboseOutput = true;
|
||||||
|
#endif
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
// Attach to the console to be able to print output.
|
||||||
|
// Since we're a /SUBSYSTEM:WINDOWS app, we won't be attached by default.
|
||||||
|
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||||
|
HANDLE conOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
if (conOut != INVALID_HANDLE_VALUE && conOut != NULL) {
|
||||||
|
freopen("CONOUT$", "w", stdout);
|
||||||
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
}
|
||||||
|
HANDLE conErr = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
if (conErr != INVALID_HANDLE_VALUE && conErr != NULL) {
|
||||||
|
freopen("CONOUT$", "w", stderr);
|
||||||
|
setvbuf(stderr, NULL, _IONBF, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue