Skip to content

Commit

Permalink
GetValueKind throws exception when not found
Browse files Browse the repository at this point in the history
IB-7521

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma authored and mrts committed Sep 23, 2022
1 parent a0d9549 commit 1ef35df
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/FirefoxAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ internal static RegistryKey OpenOrCreateSubKey(this RegistryKey registryKey, str

internal static string GetStringValue(this RegistryKey registryKey, string name, string defaultValue = null)
{
if (!registryKey.ContainsName(name))
return defaultValue;
switch (registryKey.GetValueKind(name))
{
case RegistryValueKind.String:
Expand All @@ -111,5 +113,15 @@ internal static string GetStringValue(this RegistryKey registryKey, string name,
default: return defaultValue;
}
}

internal static bool ContainsName(this RegistryKey key, string name)
{
foreach (string value in key.GetValueNames())
{
if (value == name)
return true;
}
return false;
}
}
}

0 comments on commit 1ef35df

Please sign in to comment.