From aff85d588531da64f906a07abb8a4b1785aa6c62 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 31 Jul 2011 20:09:27 +0000 Subject: [PATCH] add better diagnostics for win32 console startup --- BizHawk.MultiClient/LogConsole.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/BizHawk.MultiClient/LogConsole.cs b/BizHawk.MultiClient/LogConsole.cs index ec8e55c759..9a17ee425d 100644 --- a/BizHawk.MultiClient/LogConsole.cs +++ b/BizHawk.MultiClient/LogConsole.cs @@ -141,17 +141,24 @@ namespace BizHawk.MultiClient //stdout is already connected to something. keep using it and dont let the console interfere shouldRedirectStdout = (fileType == Win32.FileType.FileTypeUnknown || fileType == Win32.FileType.FileTypePipe); - //attach to an existing console (if we can; this is circuitous because AttachConsole wasnt added until XP) + //attach to an existing console attachedConsole = false; if (Win32.AttachConsole(-1)) + { + hasConsole = true; attachedConsole = true; + } if (!attachedConsole) { - Win32.AllocConsole(); + if (Win32.AllocConsole()) + hasConsole = true; + else + System.Windows.Forms.MessageBox.Show("Couldn't allocate win32 console: {0}" + Marshal.GetLastWin32Error()); } + if(hasConsole) { IntPtr ptr = Win32.GetCommandLine(); string commandLine = Marshal.PtrToStringAuto(ptr); @@ -166,7 +173,6 @@ namespace BizHawk.MultiClient throw new Exception("SetStdHandle() failed"); } - hasConsole = true; DotNetRewireConout(); if (attachedConsole)