C# 通过Process.Start() 打开程序 置顶方法

时间:2022-08-29 14:46:02
 1   private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
 2         {
 3             try
 4             {
 5                 foreach (var item in lis_url)
 6                 {
 7                     if (e.Url.ToString().StartsWith(item))
 8                     {
 9                         var p = Process.Start("iexplore.exe", e.Url.ToString());
10                         if (p.Start())
11                             SetForegroundWindow(p.MainWindowHandle);
12                         e.Cancel = true;
13                         break;
14                     }
15                 }
16             }
17             catch (Exception ex)
18             {
19             }
20         }
21         [DllImport("USER32.DLL")]
22         public static extern bool SetForegroundWindow(IntPtr hWnd);