/// <summary> /// Retrieves a <see cref="bool" /> value from this <see cref="RegistryKey" /> that is represented as a REG_DWORD value. Returns <see langword="null" />, if the value does not exist in the registry, is not a REG_DWORD value, or is not equal to 0 or 1. /// </summary> /// <param name="key">The <see cref="RegistryKey" /> to read the value from.</param> /// <param name="name">A <see cref="string" /> value specifying the name of the value to read.</param> /// <returns> /// <see langword="true" />, if the value is a REG_DWORD and is equal to 1; /// <see langword="false" />, if the value is a REG_DWORD and is equal to 0; /// otherwise, <see langword="null" />. /// </returns> public static bool?GetBooleanValue(this RegistryKey key, string name) { Check.ArgumentNull(key, nameof(key)); return(key.GetInt32Value(name) switch { 0 => false, 1 => true, _ => (bool?)null });