C#中引入控制台

来源:互联网 发布:php 获取1688商品价格 编辑:程序博客网 时间:2024/06/07 08:00

引入后代码中直接Console.WriteLine()打印

using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;using System.Runtime.InteropServices;namespace LegendTool{    static class Program    {        //引入控制台,看下可以吗?        [DllImport("kernel32.dll")]        static extern bool FreeConsole();        [DllImport("kernel32.dll")]        public static extern bool AllocConsole();        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [STAThread]        static void Main()        {            // LoadResoureDll.RegistDLL();            AllocConsole();//调用系统API,调用控制台窗口            Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            Application.Run(new MainForm());            FreeConsole();//释放控制台        }    }}


..