我試圖在默認瀏覽器中打開一個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