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

 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);

 

posted @ 2017-03-24 10:14  指间的徘徊  阅读(6404)  评论(0编辑  收藏  举报