我试图在默认浏览器中打开一个url。很明显,我认为Shell Exec会在默认浏览器中打开它,但它不会。注册表中的DefaultBrowser不起作用
然后我试图明确:
Process.Start(GetDefaultBrowserPath(), "http://stackoverflow.com");
private static string GetDefaultBrowserPath()
{
string key = @"htmlfile\shell\open\command";
RegistryKey registryKey =
Registry.ClassesRoot.OpenSubKey(key, false);
// get default browser path
return ((string)registryKey.GetValue(null, null)).Split('"')[1];
}
它总是返回的Internet Explorer但没有哪是Firefox的我的默认。我试了几台电脑...
我不在乎来调用默认浏览器链接哪种方式,但它是默认
当你说这是你的默认,你确定,如果您创建一个新的.html文件在你的桌面上,双击它,它实际上在Firefox中打开? – Jeff 2010-11-11 14:30:28
是的,我只是试过。桌面上的新.html文件,双击并在Firefox中打开。 – Kai 2010-11-11 14:32:18
'Process.Start(“http://stackoverflow.com”);'在我的机器上运行(打开Chrome)。 – dtb 2010-11-11 14:35:27