From: Daniel A. <dat...@us...> - 2005-07-05 03:52:58
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6866/src Modified Files: Tag: oldstatus win_gaim.c Log Message: On Windows XP or newer, try to use the existing console, if one is present. Index: win_gaim.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/win_gaim.c,v retrieving revision 1.12.2.6 retrieving revision 1.12.2.7 diff -u -d -p -r1.12.2.6 -r1.12.2.7 --- win_gaim.c 3 May 2005 04:39:20 -0000 1.12.2.6 +++ win_gaim.c 5 Jul 2005 03:52:50 -0000 1.12.2.7 @@ -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 <windows.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <stdio.h> +/** 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 @@ -278,11 +288,18 @@ WinMain (struct HINSTANCE__ *hInstance, 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) { |