想把控制台的代码在窗体中显示,然后再窗体中点击button按钮即可运行控制台的代码。
各位大虾~~~~~~~~~怎么实现啊?

解决方案 »

  1.   

    http://u2usoft.cnblogs.com/articles/332762.html
      

  2.   

    http://u2usoft.cnblogs.com/articles/332762.html这个可能对你有帮助
      

  3.   

    回答你的第一个问题:
    C#窗体如何嵌套外部程序在窗体中运行和显示?
    这个问题在CSDN论坛中很多人提过![DllImport("User32.dll ", EntryPoint = "SetParent")]
    private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    [DllImport("user32.dll ", EntryPoint = "ShowWindow")]
    public static extern int ShowWindow(IntPtr hwnd, int nCmdShow); 
    private void button1_Click(object sender, EventArgs e)
    {
        Process p = new Process();
        p.StartInfo.FileName = "cmd.exe ";
        p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;//加上这句效果更好 
        p.Start();
        System.Threading.Thread.Sleep(100);//加上,100如果效果没有就继续加大    SetParent(p.MainWindowHandle, this.Handle);
        ShowWindow(p.MainWindowHandle, 3);}
      

  4.   

    楼主的想象力真丰富!
    5楼的代码有点看不懂,"User32.dll ",这个应该是系统文件吧
    怎么用这个啊!~