111,120
社区成员
发帖
与我相关
我的任务
分享
[DllImport("user32.dll", EntryPoint = "FindWindowA")]
public static extern IntPtr FindWindowA(string lp1, string lp2);
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern bool ShowWindow(IntPtr hWnd, int _value);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
static void Main()
{
if(isRunning("进程名"))
{
IntPtr hTray = FindWindowA(null, "窗口标题"); //查找窗口
ShowWindow(hTray, 9); //如果窗口是最小化,则恢复显示窗口
SetForegroundWindow(hTray); //如果程序界面不显示在最前面,则将程序显示在最前端
}
else{.............}
}
Process myProcess = new Process();
myProcess.StartInfo.FileName = "Notepad";
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
myProcess.Start();