diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2016-11-25 06:39:30 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2016-12-23 04:54:35 +0000 |
commit | 601bdc416b6ef17498c94fec49164b1b4c38528d (patch) | |
tree | 288e261b182ba5e06a19dd761aca08cde39fd12b /desktop/win32 | |
parent | 46d3163f779a43cc7c023a6e8141f990e5d23292 (diff) |
tdf#100826: Use parent console for output if possible
This patch uses either passed standard handles, or parent console
for output of --help and --version command line switches.
Change-Id: Iabbec79d3792ae091ca06d134345c1669eb1ac13
Reviewed-on: https://gerrit.libreoffice.org/31187
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'desktop/win32')
-rw-r--r-- | desktop/win32/source/officeloader/officeloader.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index 25277f1ff143..25f35374e119 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -23,6 +23,9 @@ #include <cstddef> #include <cwchar> +#if _WIN32_WINNT < 0x0501 +#define _WIN32_WINNT 0x0501 +#endif #define WIN32_LEAN_AND_MEAN #if defined _MSC_VER #pragma warning(push, 1) @@ -71,10 +74,16 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int ) ZeroMemory( &aStartupInfo, sizeof(aStartupInfo) ); aStartupInfo.cb = sizeof(aStartupInfo); - GetStartupInfo( &aStartupInfo ); - // Create process with same command line, environment and stdio handles which // are directed to the created pipes + GetStartupInfo(&aStartupInfo); + + // If this process hasn't its stdio handles set, then check if its parent + // has a console (i.e. this process is launched from command line), and if so, + // attach to it. It will enable child process to retrieve this console if it needs + // to output to console + if ((aStartupInfo.dwFlags & STARTF_USESTDHANDLES) == 0) + AttachConsole(ATTACH_PARENT_PROCESS); DWORD dwExitCode = (DWORD)-1; |