English 中文(简体)
如何读懂VB文本中登记处的(违约)价值?
原标题:How to read the (Default) value from registry in VBScript?

在登记处,管理人是一个关键,只有价值,即<代码>(Default)。 这一违约条目具有必要的价值。 我发现一份文字读作登记处的数值。

const HKEY_LOCAL_MACHINE = &H80000002
const RegistryLocation   = "SOFTWARESAP BusinessObjectsSuite XI 4.0XcelsiusKeycodes"

ReadRegistry( RegistryLocation )

Function ReadRegistry( RegistryLocation )

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "
ootdefault:StdRegProv")

oReg.EnumValues HKEY_LOCAL_MACHINE, RegistryLocation, arrValueNames, arrValueTypes

    Wscript.Echo "Key Name: " & arrValueNames(0)
 RegKeyName = arrValueNames(0)

oReg.GetStringValue HKEY_LOCAL_MACHINE, RegistryLocation, arrValueNames(0), strValue
Wscript.Echo "Value: " & strValue
 RegKeyValue = strValue

 ChangeRegistryValue RegistryLocation, arrValueNames(i), NewSerial

End Function  ReadRegistry

该公司做的是精细的综合框架,其中更为关键。 如果只有(过失)价值,即有一类错误。 如果设定新的关键因素,则可以读到缺省入值。

因此,我的问题是,我是错了什么,我应该怎样做?

感谢!

最佳回答

看来,在只有一面价值、空名的情况下,VB文本在获得一系列价值方面存在问题。 在不列举价值名称的情况下,你可以读到缺省值——只是为价值名称提供空洞:

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "
ootdefault:StdRegProv")
oReg.GetStringValue HKEY_LOCAL_MACHINE, RegistryLocation, "", strValue
Wscript.Echo "Value: " & strValue

它在这两种情况下都发挥了作用:当违约价值是唯一的价值,而且在特定钥匙下价值更大时。

问题回答

我愿将此列为对MBu提供的答复的评论,但时间太长。

Just to clarify, this is not an issue with VBScript having a problem with getting an array of arrValueNames when there is only one value. It is actually how StdRegProv works (unfortunately). If you look at the documentation of the EnumValues method of the StdRegProv, you will understand why this is happening, below is an extract explaining this behavior:

Na

An array of named value strings. The elements of this array correspond directly to the elements of the Types parameter. Returns null if only the default value is available.

Na being arrValueNames in the code. Below is the link for the EnumValues method: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/regprov/enumvalues-method-in-class-stdregprov





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签