EpiConsole shows a Command Prompt Window for Debugging purposes
internal static class EpiConsole
{
public static void Start()
{
IntPtr hw = GetConsoleWindow();
if (hw == IntPtr.Zero) AllocConsole();
Console.Clear();
ShowWindow(hw, 8);
Debug.Listeners.Clear();
TextWriterTraceListener writer = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(writer);
}
public static void Close()
{
IntPtr hw = GetConsoleWindow();
if (hw != IntPtr.Zero) ShowWindow(hw, 0);
}
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
internal static extern int AllocConsole();
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
internal static extern int FreeConsole();
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern IntPtr GetConsoleWindow();
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}