导出控制台控制函数
/// <summary>
/// Allocates a new console for current process.
/// </summary>
[DllImport("kernel32.dll")]
public static extern Boolean AllocConsole();
/// <summary>
/// Frees the console.
/// </summary>
[DllImport("kernel32.dll")]
使用方法
程序启动的时候,调AllocConsole();
程序运行中,就可以调Console.Write();输出内容了;
程序退出的时候,调FreeConsole();