using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace 在WinForm中启动控制台
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("Kernel32.dll")]
static extern bool AllocConsole();
[DllImport("Kernel32.dll")]
static extern bool FreeConsole();
private void button1_Click(object sender, EventArgs e)
{
AllocConsole();
Console.WriteLine("hello");
//FreeConsole();释放掉
}
}
}
没有评论:
发表评论