From: <dat...@us...> - 2006-09-19 22:53:53
|
Revision: 17322 http://svn.sourceforge.net/gaim/?rev=17322&view=rev Author: datallah Date: 2006-09-19 15:53:47 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Fix stdout redirection to work for the wingaim executable even when running in the non-debug GUI subsystem. This has annoyed me for quite some time. Modified Paths: -------------- trunk/gtk/win32/win_gaim.c Modified: trunk/gtk/win32/win_gaim.c =================================================================== --- trunk/gtk/win32/win_gaim.c 2006-09-19 18:40:30 UTC (rev 17321) +++ trunk/gtk/win32/win_gaim.c 2006-09-19 22:53:47 UTC (rev 17322) @@ -224,7 +224,7 @@ printf("Trying to set SafeDllSearchMode to 0\n"); regval = 0; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "System\\CurrentControlSet\\Control\\Session Manager", + "System\\CurrentControlSet\\Control\\Session Manager", 0, KEY_SET_VALUE, &hkey ) == ERROR_SUCCESS) { if (RegSetValueEx(hkey, @@ -511,15 +511,21 @@ /* If debug or help or version flag used, create console for output */ if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) { - LPFNATTACHCONSOLE MyAttachConsole = NULL; - if ((hmod = GetModuleHandle("kernel32.dll"))) { - MyAttachConsole = - (LPFNATTACHCONSOLE) - GetProcAddress(hmod, "AttachConsole"); + /* If stdout hasn't been redirected to a file, alloc a console + * (_istty() doesn't work for stuff using the GUI subsystem) */ + if (_fileno(stdout) == -1) { + LPFNATTACHCONSOLE MyAttachConsole = NULL; + if ((hmod = GetModuleHandle("kernel32.dll"))) { + MyAttachConsole = + (LPFNATTACHCONSOLE) + GetProcAddress(hmod, "AttachConsole"); + } + if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) + || AllocConsole()) { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } } - if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) - || AllocConsole()) - freopen("CONOUT$", "w", stdout); } /* Load exception handler if we have it */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |