如题:!!!

解决方案 »

  1.   

    先用process 启动一个 cmd
    然后使用Windows api“ SetParent”
    放在指定得容器上
      

  2.   


      [DllImport("user32.dll")]
           private static extern int SetParent(IntPtr hWndChild, IntPtr hWndParent);
                  //设置被绑架程序的父窗口
                   Process process = Process.Start("cmd.exe");
                   IntPtr ParenthWnd= process.MainWindowHandle;
                   SetParent(ParenthWnd, panel.Handle);
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;namespace Sinner_Cmd
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                string run;
                run = txt_input.Text.Trim();
                //txt_OUT.Text = "";
                Process cmd = new Process();//实例化
                cmd.StartInfo.FileName = "cmd.exe";
                cmd.StartInfo.RedirectStandardInput = true;
                cmd.StartInfo.RedirectStandardOutput = true;
                cmd.StartInfo.UseShellExecute = false;
                cmd.StartInfo.CreateNoWindow = false;
                cmd.Start();
                cmd.StandardInput.WriteLine(run);
                cmd.StandardInput.WriteLine("exit");
                txt_input.Text = "";
                string info = cmd.StandardOutput.ReadToEnd();
                cmd.WaitForExit();
                cmd.Close();
                txt_OUT.AppendText(info);
            }
        }
    }
    献丑了
      

  4.   

            [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.Start();            System.Threading.Thread.Sleep(100);            SetParent(p.MainWindowHandle, this.Handle);
                ShowWindow(p.MainWindowHandle, 3);    
            }
      

  5.   

    [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);}
      

  6.   

    http://topic.csdn.net/u/20090226/17/369adba8-bb8f-41d3-b65d-c0e7a8697087.html
      

  7.   

    验证了一下  
    这位仁兄的代码可以实现内嵌cmd功能
      

  8.   

    使用管道获取dos命令的执行结果,然后用多行textbox显示。
      

  9.   

    谢谢大家的帮助了,CSDN里果然是高手好多呀,以后要多在这上面看看,散分了,分不多,12楼有重大功劳,多给呀!!