悟道人生

渴望闲云野鹤的生活,面对自然,鸟鸣虫唱,星辰为伴,没有拘束,没有苦恼,有的只是神仙般的生活

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

[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 button3_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, panel1.Handle); //panel1.Handle为要显示外部程序的容器

            ShowWindow(p.MainWindowHandle, 3);

        }

posted on 2010-05-15 10:02  凌风有约  阅读(1827)  评论(4编辑  收藏  举报