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"); } }
private static object GetValue(RegistryRootKey rootKey, [NotNull] string path, [NotNull] string name) { RegistryKey rootRegKey = GetRootKey(rootKey); return(GetValue(rootRegKey, path, name)); }
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)); }
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)); }