Saturday, 12 January 2013

Get all registry hive C#



Step 1)  Add Namespace  Microsoft.Win32

Step 2) Get All Registry hives using C#

        void Get_Registry_hives()
        {
                  String[]Registry_Hives=Enum.GetNames(typeof(RegistryHive));
                  foreach (String registryHive in Registry_Hives)
                 {
                      Console.WriteLine("Registry Hive:{0}",registryHive);
                  }
        }



Output


Registry Hive:ClassesRoot
Registry Hive:CurrentUser
Registry Hive:LocalMachine
Registry Hive:Users
Registry Hive:PerformanceData
Registry Hive:CurrentConfig
Registry Hive:DynData