[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);引用API
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);