Previous Topic: RegEnumKey - Enumerate the Subkeys of a Registry KeyNext Topic: RegOpenKey - Open a Key


RegEnumVariable - Enumerate the Variables

Valid on Windows

The RegENumVariable function enumerates the variables for the specified registry key.

Function format:

RegEnumVariable(hKey as Integer, index as Integer, name as String, strvalue as String, intvalue as Integer) as Integer
RegEnumVariable(hkey as integer, index as integer, dummy as string, name as string, bufsize as integer, buffer as void) as integer.
hKey

Identifies a currently open key or a predefined key. The hKey parameter can have one of the following predefined values available on all Windows platforms:

HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
index

Identifies the index of the variable that is to be retrieved. Use zero for the first call of the function.

name

Identifies the output parameter that is to hold the name of the requested variable.

strvalue

Identifies the output parameter that is to hold the string value of the requested variable.

intvalue

Identifies the output parameter that is to hold the integer value of the requested variable.

dummy

Reserved.

bufsize

Size of the receiving buffer in chars if the buffer is of type string; otherwise, the number of bytes are specified. Must be a variable. After a successful return, it contains the number of bytes retrieved.

buffer

Buffer to receive the retrieved value of the variable.

On successful completion, the first variant of the function returns one of the following values:

REG_NODATA

Value 0; A variable was not found. This indicates that either the last index of the enumeration has been reached or the handle was invalid.

REG_INTEGER

Value 1; An Integer type variable was found; the value will be stored in the intvalue variable.

REG_STRING

Value 2; A String type variable was found; the value will be stored in the strvalue variable.

REG_UNSUPPORTED

Value 3; An unsupported variable type was found; the value will be void.

The second variant of the function returns in Microsoft notation:

REG_NONE

Value 0

REG_SZ

Value 1

REG_EXPAND_SZ

Value 2

REG_BINARY

Value 3

REG_DWORD

Value 4

REG_DWORD_LITTLE_ENDIAN

Value 4

REG_DWORD_BIG_ENDIAN

Value 5

REG_LINK

Value 6

REG_MULTI_SZ

Value 7

Example:

Dim value as string
Dim hkey1 as integer
Dim name, str, dummy as string
Dim i, i1, rtr, int as integer
Dim bBuf[100] as Byte
Dim cBuf[100] as char

ClrScr()

hkey1 = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\CA")
if hkey1 = 0 then
	Print("RegOpenKey failed.")
	exit
endif

i = 0
while
	RegEnumKey(hkey1, i, str)
	Print(Str(i) + " - " + str)
	
RegCloseKey(hkey1)

Print " "

hkey1 = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\CA\4 test only")
if hkey1 = 0 then
	Print("RegOpenKey failed.")
	exit
endif
for i = 0 to 1
	rtr = RegEnumVariable(hKey1, i, name, str, i1)
	if (REG_INTEGER = rtr) then
		Print(Str(rtr) + ": " + Str(i) + " - " + name + " = " + Str(i1))
	else
		if (REG_STRING = rtr) then
			Print(Str(rtr) + ": " + Str(i) + " - " + name + " = " + str)
		else
			Print(Str(rtr) + ": " + "unknown type");
		endif
	endif
next i
i1 = 100
str = ""
rtr = RegEnumVariable(hKey1, 2, name, dummy, i1, bBuf))
for i = 0 to i1 - 1
	str = str + Str(bBuf[i])
next i
Print (Str(rtr) + ": " + "2 - " + name + "(" + Str(i1) + ") = " + str)