Fixed registry key access (#256)

This commit is contained in:
MaxXor 2015-06-02 20:33:37 +02:00
parent f1934058a0
commit 253507a613
1 changed files with 3 additions and 3 deletions

View File

@ -54,7 +54,7 @@ public static RegistryKey OpenReadonlySubKeySafe(this RegistryKey key, string na
{
try
{
return Registry.LocalMachine.OpenSubKey(name, false);
return key.OpenSubKey(name, false);
}
catch
{
@ -72,7 +72,7 @@ public static RegistryKey OpenReadonlySubKeySafe(this RegistryKey key, string na
/// unable to obtain a sub-key.</returns>
public static RegistryKey OpenWritableSubKey(this RegistryKey key, string name)
{
return Registry.LocalMachine.OpenSubKey(name, true);
return key.OpenSubKey(name, true);
}
/// <summary>
@ -85,7 +85,7 @@ public static IEnumerable<string> GetFormattedKeyValues(this RegistryKey key)
{
if (key == null) yield break;
foreach (var k in key.GetValueNames().Where(keyVal => !keyVal.IsNameOrValueNull(key)).Where(string.IsNullOrEmpty))
foreach (var k in key.GetValueNames().Where(keyVal => !keyVal.IsNameOrValueNull(key)).Where(k => !string.IsNullOrEmpty(k)))
{
yield return string.Format("{0}||{1}", k, key.GetValueSafe(k));
}