6

タイトルがすべてを物語っています。

4

3 に答える 3

7

デフォルトのブラウザは、Windows のレジストリ キーにエントリとして保存されます。値は、このようにプロトコルごとに保存されます

HKEY_CLASSES_ROOT\[プロトコル]\shell\open\command

プロトコルは http、https などです。C# 内のレジストリ値にアクセス/変更する方法については、この記事をご覧ください。

于 2009-06-09T06:37:44.150 に答える
5

少なくとも 2 つのRegistryKeyを変更し、代替ブラウザへのパスを設定する必要があると思います。

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 PC の場合、レジストリ キーを変更する必要があります。

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 に答える