1. 程式人生 > >c#通過瀏覽器開啟指定網址

c#通過瀏覽器開啟指定網址



匯入兩個名稱空間

using Microsoft.Win32;
using System.Text.RegularExpressions;

開啟瀏覽器

System.Diagnostics.Process.Start("iexplore.exe", "http://www.datangintel.com/");

開啟預設瀏覽器

             RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"http\shell\open\command\");
             string s = key.GetValue("").ToString();
 
             Regex reg = new Regex("\"([^\"]+)\"");
             MatchCollection matchs = reg.Matches(s);
 
             string filename="";
             if (matchs.Count > 0)   //www.2cto.com
             {
                 filename = matchs[0].Groups[1].Value;
                 System.Diagnostics.Process.Start(filename, "

http://www.datangintel.com/");
             }