這是我不得不使用EnumKey從32位應用程序到64位註冊表的代碼。
objLog.WriteLine "Begin StdRegProv reg read method"
strComputer = "."
Const HKLM = &h80000002
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
objCtx.Add "__ProviderArchitecture", 64
objCtx.Add "__RequiredArchitecture", TRUE
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objStdRegProv = objServices.Get("StdRegProv")
objLog.WriteLine "About to call EnumKey with ExecMethod"
' Use ExecMethod to call the EnumKey method
Set Inparams = objStdRegProv.Methods_("EnumKey").Inparameters
Inparams.Hdefkey = HKLM
Inparams.Ssubkeyname = sPath
'InParams.aArrayOfGuids = guidlist()
'Inparams.Svaluename = "Logging"
set Outparams = objStdRegProv.ExecMethod_("EnumKey", Inparams,,objCtx)
objLog.WriteLine "Finished creating array of guids"
'read values in array
'For Each guid In Outparams.snames
' objLog.WriteLine "these are the guids in the array - " & guid
'Next
For each guid1 in Outparams.snames
dim InstallPropertiesPath
InstallPropertiesPath = sPath & "\" & guid1 & SubPath1
objLog.WriteLine "The InstallPropertiesPath is " & InstallPropertiesPath
' Use ExecMethod to call the GetStringValue method
Set Inparams = objStdRegProv.Methods_("GetStringValue").Inparameters
Inparams.Hdefkey = HKLM
Inparams.Ssubkeyname = InstallPropertiesPath
Inparams.sValueName = "LocalPackage"
'InParams.aArrayOfGuids = guidlist()
'Inparams.Svaluename = "Logging"
set Outparams = Nothing
set Outparams = objStdRegProv.ExecMethod_("GetStringValue", Inparams,,objCtx)
objLog.WriteLine "About to call DetectMSIFeature with this path - " & Outparams.SValue
您的程序是否以管理員身份運行?它可能沒有它需要的權限。 –
它以管理員身份運行。我想我知道發生了什麼事。在Win7上,EnumKey默認爲WOW6432註冊表。我正在尋找的關鍵是在64位註冊表樹中。我將搜索如何指定要使用的註冊表的哪一部分。 –