本文实例讲述了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#程序设计有所帮助。
本文地址:https://www.stayed.cn/item/11977
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我