mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Resolving issue with Registry reads where values are not present.
This commit is contained in:
@@ -762,19 +762,21 @@ namespace System.Management.Automation
|
||||
return null;
|
||||
}
|
||||
|
||||
// verify the value kind as a string
|
||||
RegistryValueKind kind = regKey.GetValueKind(valueName);
|
||||
object regValue = regKey.GetValue(valueName);
|
||||
if (null != regValue)
|
||||
{
|
||||
// verify the value kind as a string
|
||||
RegistryValueKind kind = regKey.GetValueKind(valueName);
|
||||
|
||||
if (kind == RegistryValueKind.ExpandString ||
|
||||
kind == RegistryValueKind.String)
|
||||
{
|
||||
return regKey.GetValue(valueName) as string;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The function expected a string, but got another type. This is a coding error or a registry key typing error.
|
||||
return null;
|
||||
if (kind == RegistryValueKind.ExpandString ||
|
||||
kind == RegistryValueKind.String)
|
||||
{
|
||||
return regValue as string;
|
||||
}
|
||||
}
|
||||
|
||||
// The function expected a string, but got another type or the value doesn't exist.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user