summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog1
-rw-r--r--src/sdk/console.h16
2 files changed, 13 insertions, 4 deletions
diff --git a/Changelog b/Changelog
index 021e0763b..6fe9da5f0 100644
--- a/Changelog
+++ b/Changelog
@@ -19,6 +19,7 @@
- Renamed settings inside config.xml:
- UninstallerName renamed to MaintenanceToolName (default value changed to "maintenancetool")
- UninstallerIniFile renamed to MaintenanceToolIniFile
+- Windows: Re-use parent console for verbose output if possible
Thanks go to Sze Howe Koh, Ray Donnelly and Sascha Cunz for contributions.
diff --git a/src/sdk/console.h b/src/sdk/console.h
index 7eb4aa3f4..8e627574d 100644
--- a/src/sdk/console.h
+++ b/src/sdk/console.h
@@ -68,6 +68,10 @@ class Console
public:
Console()
{
+ parentConsole = AttachConsole(ATTACH_PARENT_PROCESS);
+ if (parentConsole)
+ return;
+
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE) {
@@ -102,16 +106,20 @@ public:
~Console()
{
- system("PAUSE");
+ if (!parentConsole) {
+ system("PAUSE");
- std::cin.rdbuf(m_oldCin);
- std::cerr.rdbuf(m_oldCerr);
- std::cout.rdbuf(m_oldCout);
+ std::cin.rdbuf(m_oldCin);
+ std::cerr.rdbuf(m_oldCerr);
+ std::cout.rdbuf(m_oldCout);
+ }
FreeConsole();
}
private:
+ bool parentConsole;
+
std::ifstream m_newCin;
std::ofstream m_newCout;
std::ofstream m_newCerr;