Exemple #1
0
        private void CloneClassesRootKeys(RegistryKey registryKey, DtoFileInfo dtoFileInfo)
        {
            RegistryKey    mainSubKey, newsubKey;
            DtoRegistryKey dtoRegistryKey;

            try
            {
                mainSubKey = registryKey?.OpenSubKey(dtoFileInfo.OriginalExtension, RegistryKeyPermissionCheck.ReadWriteSubTree);
                if (mainSubKey == null ||
                    registryKey.GetSubKeyNames().Any(keyName => keyName == dtoFileInfo.ReplacedExtension))
                {
                    return;
                }
                newsubKey      = registryKey.CreateSubKey(dtoFileInfo.ReplacedExtension);
                dtoRegistryKey = new DtoRegistryKey {
                    CreateDateTime = DateTime.Now, Name = newsubKey.Name
                };
                boRegistryKey.Save(dtoRegistryKey);
                _dtoLog.AddRegistryKey(dtoRegistryKey);
            }
            catch (Exception e)
            {
                return;
            }
            CloneRegKeysAndValues(mainSubKey, newsubKey, dtoRegistryKey);
        }
Exemple #2
0
 private void CloneSubKeyList(IEnumerable <string> subKeyNamesList, RegistryKey mainKey, RegistryKey newKey, DtoRegistryKey dtoRegistryKey)
 {
     foreach (var subKeyName in subKeyNamesList)
     {
         var newSubKey            = newKey.CreateSubKey(subKeyName);
         var newSubDtoRegistryKey = new DtoRegistryKey {
             CreateDateTime = DateTime.Now, Name = newSubKey.Name
         };
         boRegistryKey.Save(newSubDtoRegistryKey);
         dtoRegistryKey.AddRegistryKey(newSubDtoRegistryKey);
         boRegistryKey.Save(dtoRegistryKey);
         RegistryKey newMainSubKey;
         try
         {
             newMainSubKey = mainKey.OpenSubKey(subKeyName, RegistryKeyPermissionCheck.ReadWriteSubTree);
         }
         catch (Exception e)
         {
             return;
         }
         CloneRegKeysAndValues(newMainSubKey, newSubKey, newSubDtoRegistryKey);
     }
 }
Exemple #3
0
 private void CloneValueList(IEnumerable <string> valueNamesList, RegistryKey subKey, RegistryKey newSubKey, DtoRegistryKey dtoRegistryKey)
 {
     foreach (var valueName in valueNamesList)
     {
         var value = subKey.GetValue(valueName);
         var newDtoRegistryValue = new DtoRegistryValue {
             CreateDateTime = DateTime.Now, Name = valueName, Value = value.ToString()
         };
         boRegistryValue.Save(newDtoRegistryValue);
         dtoRegistryKey.AddRegistryValue(newDtoRegistryValue);
         boRegistryKey.Save(dtoRegistryKey);
         newSubKey.SetValue(valueName, value);
     }
 }
Exemple #4
0
        private void CloneRegKeysAndValues(RegistryKey mainSubKey, RegistryKey newsubKey, DtoRegistryKey dtoRegistryKey)
        {
            var subKeyList   = mainSubKey.GetSubKeyNames();
            var subValueList = mainSubKey.GetValueNames();

            if (subValueList.Any())
            {
                CloneValueList(subValueList, mainSubKey, newsubKey, dtoRegistryKey);
            }
            if (subKeyList.Any())
            {
                CloneSubKeyList(subKeyList, mainSubKey, newsubKey, dtoRegistryKey);
            }
        }