C#使用默认浏览器打开指定网页
原理:通过注册表取得默认浏览器的路径,然后用进程打开即可。
1.引用命名空间
using System.Text.RegularExpressions;
using Microsoft.Win32;
2.将如下代码插入指定位置:
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)
{
filename = matchs[0].Groups[1].Value;
System.Diagnostics.Process.Start(filename, "http://www.5566.net") ;
}