C#调用外部exe并置顶

[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);

private void button1_click(object sender, EventArgs e)
{
   OpenEXE("d:\Test\Test.exe");
}

private void OpenEXE(string exePath)
 {
     Process pro = new Process();
     pro.StartInfo.FileName = exePath;
     if (pro.Start())
         SetForegroundWindow(pro.MainWindowHandle);//置顶
 }

你可能感兴趣的:(C#调用外部exe并置顶)