本文實例講述了C#使用默認瀏覽器打開網頁的方法。分享給大家供大家參考。具體實現方法如下:
public static bool OpenBrowser(String url) {   RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"http/shell/open/command/");   String s = key.GetValue("").ToString();   String browserpath = null;   if (s.StartsWith("/""))   {     browserpath = s.Substring(1, s.IndexOf('/"', 1) - 1);   }   else   {     browserpath = s.Substring(0, s.IndexOf(" "));   }   return System.Diagnostics.Process.Start(browserpath, url)!=null; }希望本文所述對大家的C#程序設計有所幫助。
新聞熱點
疑難解答