我有一个代码,用于检查是否存在的注册表项值。它仅适用于无二进制值,如果目标路径是二进制值,则它无法检查它并且会告诉该密钥不存在。
以下是代码:
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "System\CurrentControlSet\Control\Stranger"
strValueName = "TargetBinaryKey"
objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
If IsNull(strValue) Then
WScript.Echo "The Key Does Not Exists."
Else
WScript.Echo "The Key Exists."
End If
我该怎么办?
答案 0 :(得分:1)
您应该使用.enumValues
代替.GetStringValue
。你可以找到code snippet here
另外:如果您正确地知道值为stored as binary
,您也可以使用GetBinaryValue