直接上代码
/// <summary>
/// 透过默认浏览器打开网页
/// </summary>
/// <param name="url">需要开启的URL</param>
/// <returns></returns>
private static bool OpenBrowser(string url)
{
RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"http\shell\open\command\");
string val = key.GetValue("").ToString();
string browserpath = null;
if (val.StartsWith("\""))
{
browserpath = val.Substring(1, val.IndexOf('\"', 1) - 1);
}
else
{
browserpath = val.Substring(0, val.IndexOf(" "));
}
return System.Diagnostics.Process.Start(browserpath, url) != null;
}
微信扫码查看本文
发表评论