Exemple #1
0
        private static RegistryKey GetRootKey(RegistryRootKey rootKey)
        {
            switch (rootKey)
            {
            case RegistryRootKey.Classes:
                return(Registry.ClassesRoot);

            case RegistryRootKey.CurrentUser:
                return(Registry.CurrentUser);

            case RegistryRootKey.LocalMachine:
                return(Registry.LocalMachine);

            case RegistryRootKey.Users:
                return(Registry.Users);

            case RegistryRootKey.CurrentConfig:
                return(Registry.CurrentConfig);

            case RegistryRootKey.PerformanceData:
                return(Registry.PerformanceData);

            default:
                throw new ArgumentOutOfRangeException(nameof(rootKey), rootKey,
                                                      "Unsupported root key");
            }
        }
Exemple #2
0
        private static object GetValue(RegistryRootKey rootKey,
                                       [NotNull] string path,
                                       [NotNull] string name)
        {
            RegistryKey rootRegKey = GetRootKey(rootKey);

            return(GetValue(rootRegKey, path, name));
        }
Exemple #3
0
        public static int?GetInt32(RegistryRootKey rootKey,
                                   [NotNull] string path,
                                   [NotNull] string name)
        {
            object value = GetValue(rootKey, path, name);

            return(value == null
                                       ? (int?)null
                                       : Convert.ToInt32(value));
        }
Exemple #4
0
        public static string GetString(RegistryRootKey rootKey,
                                       [NotNull] string path,
                                       [NotNull] string name)
        {
            object value = GetValue(rootKey, path, name);

            return(value == null
                                       ? null
                                       : Convert.ToString(value));
        }