aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/filelink/FileLink.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/launcher/filelink/FileLink.cpp b/launcher/filelink/FileLink.cpp
index c9599b82..e549fbe6 100644
--- a/launcher/filelink/FileLink.cpp
+++ b/launcher/filelink/FileLink.cpp
@@ -37,11 +37,7 @@
#include <sys.h>
#if defined Q_OS_WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <stdio.h>
-#include <windows.h>
+#include "WindowsConsole.h"
#endif
// Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header
@@ -67,21 +63,7 @@ FileLinkApp::FileLinkApp(int& argc, char** argv) : QCoreApplication(argc, argv),
{
#if defined Q_OS_WIN32
// attach the parent console
- if (AttachConsole(ATTACH_PARENT_PROCESS)) {
- // if attach succeeds, reopen and sync all the i/o
- if (freopen("CON", "w", stdout)) {
- std::cout.sync_with_stdio();
- }
- if (freopen("CON", "w", stderr)) {
- std::cerr.sync_with_stdio();
- }
- if (freopen("CON", "r", stdin)) {
- std::cin.sync_with_stdio();
- }
- auto out = GetStdHandle(STD_OUTPUT_HANDLE);
- DWORD written;
- const char* endline = "\n";
- WriteConsole(out, endline, strlen(endline), &written, NULL);
+ if (AttachWindowsConsole()) {
consoleAttached = true;
}
#endif