winform调用exe

private void button1_Click(object sender, EventArgs e)

{

System.Diagnostics.Process p = System.Diagnostics.Process.Start("calc");//notepad");

p.WaitForInputIdle();

SetParent(p.MainWindowHandle, this.Handle);

ShowWindowAsync(p.MainWindowHandle, 3);

}

[DllImport("user32.dll")]

static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

[DllImport("user32.dll")]

private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

你可能感兴趣的:(winform调用exe)