C#窗体程序打开控制台

it2024-07-02  42

public Form1() { InitializeComponent(); } [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")] public static extern void FreeConsole();//关闭控制台 private void Form1_Load(object sender, EventArgs e) { AllocConsole(); //开启控制台 } }
最新回复(0)