diff options
author | Fridrich Strba <fridrich.strba@bluewin.ch> | 2009-07-04 01:05:44 +0800 |
---|---|---|
committer | Fridrich Strba <fridrich.strba@bluewin.ch> | 2009-07-04 01:05:44 +0800 |
commit | cc1e4cfed27eb1f14f38499ecc147a532ff3cdd0 (patch) | |
tree | 33502912eda82ae5852a89d15813ee101f170ba2 /shell | |
parent | 266d51479ab6bc1fb2afddf73ef275047e6ced37 (diff) | |
download | gsoc2013-evolution-cc1e4cfed27eb1f14f38499ecc147a532ff3cdd0.tar.gz gsoc2013-evolution-cc1e4cfed27eb1f14f38499ecc147a532ff3cdd0.tar.zst gsoc2013-evolution-cc1e4cfed27eb1f14f38499ecc147a532ff3cdd0.zip |
[win32] When started from a console, get console output (Windows XP or
later only).
Diffstat (limited to 'shell')
-rw-r--r-- | shell/main.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/shell/main.c b/shell/main.c index 2eb2b2a5f3..54d118a41d 100644 --- a/shell/main.c +++ b/shell/main.c @@ -27,6 +27,12 @@ #ifdef G_OS_WIN32 #define WIN32_LEAN_AND_MEAN +#ifdef DATADIR +#undef DATADIR +#endif +#include <io.h> +#include <conio.h> +#define _WIN32_WINNT 0x0500 #include <windows.h> #endif @@ -566,6 +572,28 @@ gint main (gint argc, gchar **argv) { #ifdef G_OS_WIN32 + if (fileno (stdout) != -1 && + _get_osfhandle (fileno (stdout)) != -1) + { + /* stdout is fine, presumably redirected to a file or pipe */ + } + else + { + typedef BOOL (* WINAPI AttachConsole_t) (DWORD); + + AttachConsole_t p_AttachConsole = + (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); + + if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) + { + freopen ("CONOUT$", "w", stdout); + dup2 (fileno (stdout), 1); + freopen ("CONOUT$", "w", stderr); + dup2 (fileno (stderr), 2); + + } + } + extern void link_shutdown (void); #endif |