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, optional]  uint32 hDefKey = HKEY_LOCAL_MACHINE,
  [in]            string sSubKeyName,
  [in]            string sValueName,
  [out]           uint32 uValue


hDefKey [in, optional]

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 (0x80000000))
HKEY_CURRENT_USER (2147483649 (0x80000001))
HKEY_LOCAL_MACHINE (2147483650 (0x80000002))
HKEY_USERS (2147483651 (0x80000003))
HKEY_CURRENT_CONFIG (2147483653 (0x80000005))
HKEY_DYN_DATA (2147483654 (0x80000006))
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.


For script code examples, see WMI Tasks: Registry and the TechNet ScriptCenter Script Repository. Other examples are in books and articles listed in Further Information.

For C++ code examples, see WMI C++ Application Examples.

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 XP

Minimum supported server

Windows Server 2003







See also

Modifying the System Registry
WMI Tasks: Registry



© 2014 Microsoft. All rights reserved.