从注册表中读取默认浏览器可执行文件路径
private void button1_Click(object sender, EventArgs e)
{
//从注册表中读取默认浏览器可执行文件路径
RegistryKey key = Registry.ClassesRoot.OpenSubKey(@httpshellopencommand);
string s = key.GetValue().ToString();
//s就是默认浏览器,不过后面带了参数,把它截去,不过需要注意的是:不同的浏览器后面的参数不一样!
//D:Program Files (x86)GoogleChromeApplicationchrome.exe -- %1
System.Diagnostics.Process.Start(s.Substring(0, s.Length - 8), http://blog.csdn.net/testcs_dn);
}
你把linklabel点击事件LinkClicked改写为
System.Diagnostics.Process.Start("explorer.exe", "http://www.baidu.com");
貌似打开网页的时候就用的默认浏览器 如果你的意思是用自己想用的浏览器打开的话 那就要写入你要调用的浏览器路径及.exe文件例如
System.Diagnostics.Process.Start
(@"C:\Program Files\360\360se\360se.exe", "http://www.baidu.com");
using Microsoft.Win32;
RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"http\shell\open\command\");
string s = key.GetValue("").ToString();
s就是你的默认浏览器,不过后面带了参数,把它截去
System.Diagnostics.Process.Start(s.Substring(0, s.Length - 5), "http://www.baidu.com");