2012年5月10日 星期四

Output To Console In Windows Forms Application



using System.Runtime.InteropServices;


public class Win32

{ /// /// Allocates a new console for current process. ///

[DllImport("kernel32.dll")]

public static extern Boolean AllocConsole(); /// /// Frees the console. ///

[DllImport("kernel32.dll")]

public static extern Boolean FreeConsole();

}




public Form1()

{

InitializeComponent(); 
Win32.AllocConsole();

}

在需要的地方插入下Code:

沒有留言: