[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);//置顶
}
网友评论