2009-06-09 2 views
5

제목을 사용하여 기본 브라우저를 변경하면 모두 그것을 말합니다.어떻게 C# 또는 배치 파일

HKEY_CLASSES_ROOT\http\shell\open\command 
HKEY_CLASSES_ROOT\htmlfile\shell\open\command 

alternative 셸 키에 추가 항목을 작성하고 기본 동작으로 설정 할 수 있습니다 :

+1

당신이에 대한 몇 가지 세부 사항을 추가 할 수 있습니다 - 당신은 이전에 비스타 운영 체제에 대한 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"); } 

를 사용하는 것으로 변경할 수 있습니다 ? – jerryjvl

+0

개발할 때 기본 브라우저를 전환하는 빠른 방법을 사용할 수 있습니다. – Nifle

+0

그는 왜 세부 사항을 제시해야합니까? 질문은 간단합니다. – msbg

답변

5

난 당신이이어야 두 RegistryKeys을 수정하고 대체 브라우저의 경로를 설정해야합니다 생각 :

[HKEY_CLASSES_ROOT\http\shell] 
(default) set to OpenWithMyBrowser 

[HKEY_CLASSES_ROOT\http\shell\OpenWithMyBrowser\command] 
(default) set to "MyBrowser.exe" 
+0

이것은 매우 도움이 된 감사입니다. –

7

기본 브라우저는 Windows의 레지스트리 키에 항목으로 저장됩니다. 값이

HKEY_CLASSES_ROOT의 \ [프로토콜] \ 셸 \ 열려 \ 명령과 같은 프로토콜을 기준으로 저장됩니다

프로토콜은 HTTP, HTTPS 등 레지스트리를 수정/액세스하는 방법을가 될 수 있습니다 C#을 내부 값은, 당신은 당신이

HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\ Associations\UrlAssociations\http 

에 대한 레지스트리 키를 변경해야 Windows 용 7 PC를 this article

1

좀 걸릴 수 있습니다 당신이하려고하는 *이 일부 컨텍스트를 제공하는 이유 (* 윈도우 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); 
     } 
    }