gaim/gaim

d3ab5f61e3be
Parents b3b093697410
Children ac31b1bdfd6d
On Windows XP or newer, try to use the existing console, if one is present.
--- a/ChangeLog.win32 Mon Jul 04 22:03:17 2005 -0400
+++ b/ChangeLog.win32 Mon Jul 04 23:52:50 2005 -0400
@@ -1,5 +1,6 @@
version 1.4.0:
- * No changes
+ * On Windows XP or newer, the non-debug version of gaim will attempt to
+ use the existing console, if one is present, for debug output.
version 1.3.1 (6/9/2005):
* Installer allows you to choose whether or not to put shortcuts on the
--- a/src/win_gaim.c Mon Jul 04 22:03:17 2005 -0400
+++ b/src/win_gaim.c Mon Jul 04 23:52:50 2005 -0400
@@ -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 @@
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) {