调用第三方程序,指定父窗体

[DllImport("user32.dll")]
        
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        [DllImport(
"user32.dll")]
        
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

        
private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process p 
= System.Diagnostics.Process.Start("calc");
            p.WaitForInputIdle();
            SetParent(p.MainWindowHandle, 
this.splitContainer1.Panel2.Handle);
            ShowWindowAsync(p.MainWindowHandle, 
3);
        }
posted @ 2011-07-31 23:11  kenter  阅读(262)  评论(0编辑  收藏  举报