The
EnumValues method enumerates the values of the given subkey. If it has not been changed, the default value of the registry key is always returned. The method returns an empty string ("") if the data is empty.
For more information about accessing the registry with WMI, see Obtaining Registry Data.
This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see
Calling a Method.
Syntax
uint32 EnumValues(
[in, optional] uint32 hDefKey = 2147483650,
[in] string sSubKeyName,
[out] string sNames[],
[out] sint32 Types[]
);
Parameters
- hDefKey [in, optional]
-
A registry tree, also known as a hive, that contains the sSubKeyName path. The default value is HKEY_LOCAL_MACHINE.
Be aware that HKEY_DYN_DATA is a valid tree only for computers running on the Windows 95 or Windows 98 operating system.
The following trees are defined in Winreg.h.
| Name | Value |
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 to be enumerated.
- sNames [out]
-
An
array of named value strings. The elements of this array correspond directly to the elements of the Types parameter.
- Types [out]
-
An array of data value types (integers). You can use these types to determine which of the several
Get methods to call. For example, if the data value type is REG_SZ, you call
the GetStringValue method to retrieve the named value's data value. The elements of this array correspond directly with the elements of the sNames parameter.
The following data value types are defined in Winnt.h:
- REG_SZ (1)
- REG_EXPAND_SZ (2)
- REG_BINARY (3)
- REG_DWORD (4)
- REG_MULTI_SZ (7)
Return 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.
Examples
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 enumerate the
values under:
HKEY_LOCAL_MACHINE\SYSTEM\Current Control Set\Control\Lsa
You can save the script as a file with a .vbs extension and send the output to a file by executing the command line in the folder that contains the script:
cscript Filename.vbs > output.txt
const HKEY_LOCAL_MACHINE = &H80000002
const REG_SZ = 1
const REG_EXPAND_SZ = 2
const REG_BINARY = 3
const REG_DWORD = 4
const REG_MULTI_SZ = 7
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\Lsa"
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath,_
arrValueNames, arrValueTypes
For I=0 To UBound(arrValueNames)
WScript.Echo "Value Name: " & arrValueNames(I)
Select Case arrValueTypes(I)
Case REG_SZ
WScript.Echo "Data Type: String"
Case REG_EXPAND_SZ
WScript.Echo "Data Type: Expanded String"
Case REG_BINARY
WScript.Echo "Data Type: Binary"
Case REG_DWORD
WScript.Echo "Data Type: DWORD"
Case REG_MULTI_SZ
WScript.Echo "Data Type: Multi String"
End Select
Next
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| MOF | Regevent.mof |
| DLL | Stdprov.dll |
| Namespace | \root\default |
See Also
- StdRegProv
- Modifying the System Registry
- WMI Tasks: Registry
Send comments about this topic to Microsoft
Build date: 11/3/2009