标题说明了一切。
pra che
问问题
9805 次
3 回答
7
默认浏览器保存为 Windows 注册表项中的条目。这些值像这样以协议为基础保存
HKEY_CLASSES_ROOT\[协议]\shell\open\command
其中协议可以是http、https等。关于如何在C#中访问/修改注册表值,可以看一下这篇文章
于 2009-06-09T06:37:44.150 回答
5
我认为您需要修改至少两个RegistryKeys并将路径设置为备用浏览器:
HKEY_CLASSES_ROOT\http\shell\open\command
HKEY_CLASSES_ROOT\htmlfile\shell\open\command
另一种方法可能是在 Shell 键下创建一个附加条目并将其设置为默认操作:
[HKEY_CLASSES_ROOT\http\shell]
(default) set to OpenWithMyBrowser
[HKEY_CLASSES_ROOT\http\shell\OpenWithMyBrowser\command]
(default) set to "MyBrowser.exe"
于 2009-06-09T06:35:31.567 回答
2
对于 Windows 7 电脑,您需要更改注册表项
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\http
您可以使用 c# 更改它
RegistryKey regkey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\shell\\Associations\\UrlAssociations\\http\\UserChoice", true);
string browser = regkey.GetValue("Progid").ToString();
if (browser != "IE.HTTP")
{
regkey.SetValue("Progid", "IE.HTTP");
}
在 vista os 之前 - (在 windows XP 中检查)
RegistryKey regkey = Registry.ClassesRoot.OpenSubKey("http\\shell\\open\\command", true);
string browser = regkey.GetValue(null).ToString().ToLower().Replace("\"", "");
string defBrowser = "";
if (!browser.EndsWith("exe"))
{
//get rid of everything after the ".exe"
browser = browser.Substring(0, browser.LastIndexOf(".exe") + 4);
defBrowser = browser.Substring(browser.LastIndexOf("\\") + 1);
}
if (defBrowser != "iexplore")
{
Process.Start("IExplore.exe");
ScreenScraperEngine.Instance.Wait(2000);
string iepath = "";
foreach (Process p in Process.GetProcesses())
{
if (p.ProcessName == "IEXPLORE")
{
iepath = p.MainModule.FileName;
}
}
if (iepath != "")
{
string iepathval = "\"" + iepath + "\" -nohome";
regkey.SetValue(null, iepathval);
}
}
于 2012-07-09T04:41:12.953 回答