2009-06-09 16 views

Respuesta

5

creo que tendrá que modificar al menos dos RegistryKeys y establecer la ruta de acceso al navegador alternativo:

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

Un alternative puede ser la creación de una entrada adicional en la clave Shell y configurarlo como la acción predeterminada :

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

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

Esto fue muy útil gracias. –

7

El navegador predeterminado se guarda como una entrada en la clave de registro de Windows. Los valores se guardan en una base de protocolo como esto

HKEY_CLASSES_ROOT \ [Protocolo] \ shell \ open \ command

Dónde protocolo puede ser http, https, etc. En la forma de acceder/modificar registro valores dentro de C#, se puede echar un vistazo a this article

1

para los PC con windows 7 necesita cambiar la clave de registro para

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

esto se puede cambiar usando 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"); 
} 

para antes del sistema operativo Vista - (comprobado en 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); 
     } 
    } 
Cuestiones relacionadas