Reads path of default browser from registry - CSharp Operating System

CSharp examples for Operating System:Browser

Description

Reads path of default browser from registry

Demo Code


using Microsoft.Win32;

public class Main{
        /// <summary>
      /// Reads path of default browser from registry
      /// </summary>
      /// <returns></returns>
      internal static string GetDefaultBrowserPath()
      {/*from  ww  w . ja  v a2s  .co m*/
         try
         {
            string key = @"htmlfile\shell\open\command";
            RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(key, false);

            // get default browser path
            return ((string)registryKey.GetValue(null, null)).Split('"')[1];
         }
         catch
         {
            return "iexplore";
         }
      }
}

Related Tutorials