mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Resolving issue with Registry reads where values are not present.
This commit is contained in:
1 parent
6eb0f2d6c7
commit
d3625f7662
1 file changed
+13
-11
@@ -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