I use this to get the default web browser path and executable:
public static string DefaultWebBrowser { get { string path = @"\http\shell\open\command"; using (RegistryKey reg = Registry.ClassesRoot.OpenSubKey(path)) { if (reg != null) { string webBrowserPath = reg.GetValue(String.Empty) as string; if (!String.IsNullOrEmpty(webBrowserPath)) { if (webBrowserPath.First() == '"') { return webBrowserPath.Split('"')[1]; } return webBrowserPath.Split(' ')[0]; } } return null; } } }
and
protected static bool Run(string FileName, string Args) { try { Process proc = new Process(); processInfo.FileName = FileName; proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal; if(Args != null) proc.StartInfo.Arguments = Args; proc.Start(); return true; } catch (Exception) { } return false; }
Then I call the web browser: Run(DefaultWebBrowser, "foo.html")
Question: I have a problem. The above function calls firefox and IE (two web browsers installed on my computer), and not Internet Explorer, the default web browser. I do not know how to fix this. Any help is greatly appreciated. Thanks in advance.
EDIT
I downloaded and installed Google Chrome, installed it as the default web browser, but, oddly enough, the above error does not occur with it.
source share