diff options
| author | Ted Gould <ted@gould.cx> | 2010-03-26 04:34:25 +0000 |
|---|---|---|
| committer | Ted Gould <ted@gould.cx> | 2010-03-26 04:34:25 +0000 |
| commit | 9e023a3aa964a0d3fa1e31e46d33657367ba68aa (patch) | |
| tree | 33f1392a340737e4eeefca6fd031f96c29befd2b /src/winmain.cpp | |
| parent | Installing the pkgconfig file (diff) | |
| parent | Adding in shape-record.h (diff) | |
| download | inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.tar.gz inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.zip | |
Merge from trunk
(bzr r8254.1.53)
Diffstat (limited to 'src/winmain.cpp')
| -rw-r--r-- | src/winmain.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/winmain.cpp b/src/winmain.cpp index dc6b7e008..752ab8e6b 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -6,8 +6,12 @@ #include <glib.h> #ifdef G_OS_WIN32 - #undef DATADIR + +#include <stdio.h> +#include <io.h> +#include <conio.h> +#define _WIN32_WINNT 0x0501 #include <windows.h> extern int main (int argc, char **argv); @@ -26,6 +30,28 @@ WinMain (struct HINSTANCE__ *hInstance, char *lpszCmdLine, int nCmdShow) { + 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); + + } + } + int ret; ret = main (__argc, __argv); return ret; |
