Last active
January 4, 2018 01:04
-
-
Save seayxu/7581885ea80597f71786 to your computer and use it in GitHub Desktop.
Show console in csharp winform func
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Demo | |
{ | |
static class Program | |
{ | |
[DllImport("kernel32.dll")] | |
static extern bool FreeConsole();//Call Sysytem API,Disposed Console | |
[DllImport("kernel32.dll")] | |
public static extern bool AllocConsole();//Call Sysytem API,Show Console | |
[STAThread] | |
static void Main() | |
{ | |
Application.EnableVisualStyles(); | |
Application.SetCompatibleTextRenderingDefault(false); | |
AllocConsole();//Show Console | |
Application.Run(new Form1()); | |
FreeConsole();//Disposed Console | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment