如何通过C#程序打开程序并给予该程序重点
如何通过C#程序(Windows Mobile)打开程序并重点关注该程序?
由MarkJ编辑 :Gold表示感谢Process.Start建议,但出于某种原因,该计划仍未得到关注。
在此先感谢,金
您可以通过调用Process.Start
启动程序,如下所示:
Process.Start(programPath);
您还可以传入文件(例如,Word文档),甚至是网站,它将自动在用户计算机上的该文件类型的默认程序中启动。
当您调用Process.Start
,程序应自动获得焦点。
您可以使用Process.Start();
开始你的过程,然后:
[DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool SetForegroundWindow(IntPtr hWnd); public static bool BringWindowToTop(string windowName, bool wait) { int hWnd = FindWindow(windowName, wait); if (hWnd != 0) { return SetForegroundWindow((IntPtr)hWnd); } return false; }
找到窗口并把它带到前面
Process.Start()
??
使用下面的代码应该自动将窗口置于顶部。
Process.Start("path");