# HG changeset patch # User Daniel Atallah # Date 1120535686 0 # Node ID 52d6b10025ca26735972980ba16493f8680355ce # Parent c86d423df757be93d04de031dec9f55739f3b197 [gaim-migrate @ 13014] On Windows XP or newer, try to use the existing console, if one is present. committer: Tailor Script diff -r c86d423df757 -r 52d6b10025ca src/win_gaim.c --- a/src/win_gaim.c Tue Jul 05 03:08:49 2005 +0000 +++ b/src/win_gaim.c Tue Jul 05 03:54:46 2005 +0000 @@ -24,14 +24,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ + +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +#endif #include #include #include #include #include +/** Currently missing from win32-api */ +#ifndef ATTACH_PARENT_PROCESS +# define ATTACH_PARENT_PROCESS -1 +#endif + typedef int (CALLBACK* LPFNGAIMMAIN)(HINSTANCE, int, char**); typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCTSTR); +typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD); /* * PROTOTYPES @@ -289,11 +299,18 @@ char gaimdir[MAX_PATH]; HMODULE hmod; - /* If debug flag used, create console for output */ - if(strstr(lpszCmdLine, "-d")) { - if(AllocConsole()) - freopen ("CONOUT$", "w", stdout); - } + /* If debug or help flag used, create console for output */ + if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h")) { + LPFNATTACHCONSOLE MyAttachConsole = NULL; + if ((hmod = GetModuleHandle("kernel32.dll"))) { + MyAttachConsole = + (LPFNATTACHCONSOLE) + GetProcAddress(hmod, "AttachConsole"); + } + if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS)) + || AllocConsole()) + freopen("CONOUT$", "w", stdout); + } /* Load exception handler if we have it */ if(GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) {