GetDWORDValue method of the StdRegProv class
The GetDWORDValue method returns the data value for a named value whose data type is REG_DWORD.
This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.
uint32 GetDWORDValue(
[in] uint32 hDefKey = HKEY_LOCAL_MACHINE,
[in] string sSubKeyName,
[in] string sValueName,
[out] uint32 uValue
);
-
hDefKey [in]
-
A registry tree, also known as a hive, that contains the sSubKeyName path. The default value is HKEY_LOCAL_MACHINE.
The following trees are defined in WinReg.h.
-
HKEY_CLASSES_ROOT (2147483648)
-
HKEY_CURRENT_USER (2147483649)
-
HKEY_LOCAL_MACHINE (2147483650)
-
HKEY_USERS (2147483651)
-
HKEY_CURRENT_CONFIG (2147483653)
-
HKEY_DYN_DATA (2147483654)
sSubKeyName [in]
A path that contains the named values.
sValueName [in]
A named value whose data value you are retrieving. Specify an empty string to get the default named value.
uValue [out]
A DWORD data value for the named value.
In C++, the method returns a uint32 value that is 0 (zero) if successful. If the function fails, the return value is a nonzero error code that is defined in WinError.h. In C++, use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error. You can also look up return values under the WMI Error Constants.
In scripting or Visual Basic, the method returns an integer value that is 0 (zero) if successful. If the function fails, the return value is a nonzero error code that you can look up in WbemErrorEnum.
The majority of registry values that hold useful information for a system administrator are made up of either alphanumeric characters (REG_SZ) or numbers (REG_DWORD). String values in the registry are often clearly interpretable words, such as the name of a component manufacturer. Registry values of other types, like binary values, cannot be interpreted quite so readily.
You can read REG_SZ and REG_DWORD values by using the GetStringValue and the GetDWORDValue methods, respectively.
The following VBScript code example shows how to read and display the value in the DWORD registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\AutoReboot.
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\CrashControl"
strValueName = "AutoReboot"
oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
WScript.Echo "SYSTEM\CurrentControlSet\Control\" _
& "CrashControl\AutoReboot" _
& " = " & dwValue
Minimum supported client |
Windows Vista |
Minimum supported server |
Windows Server 2008 |
Namespace |
Root\default |
Header |
|
MOF |
|
DLL |
|