namespace CommonTool
{
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main()
{
if (GbAppConfiguration.IsOpenDebugConsole)
{
AllocConsole();
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
// Application.Run(new DemoForm());
if (GbAppConfiguration.IsOpenDebugConsole)
{
FreeConsole();
}
}
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
static extern bool AllocConsole();
[System.Runtime.InteropServices.DllImport("Kernel32")]
static extern void FreeConsole();
}
}
关键代码
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
static extern bool AllocConsole();
[System.Runtime.InteropServices.DllImport("Kernel32")]
static extern void FreeConsole();