Admin Production ni-theme
Current Publication

RegEnumerateKey

LabWindows/CVI

RegEnumerateKey

int RegEnumerateKey (unsigned int rootKey, const char subkeyName[], unsigned int index, char keyName[], unsigned int *keyNameLength);

Purpose

This function enumerates the subkeys for the specified key in the Windows Registry. This function copies one indexed subkey name for the key each time it is called. You must specify a Root Key, a Subkey of that Root Key, and index of the subkey which you want to read.

If you do not know how large a buffer to pass for the keyName parameter, you may pass NULL. The function will determine the length of the key name and return it through keyNameLength. You may then use this value to allocate appropriate space for the data, and call the function again.

Example:

unsigned char string[512];
unsigned int size,numKeys,i;
char keyName[MAX_PATH];

RegQueryInfoOnKey (REGKEY_HKLM, "Software\\MySubKey",
                   &numKeys, NULL, NULL, NULL, NULL);
for(i=0;i<numKeys;++i) {

size = MAX_PATH;
RegEnumerateKey (REGKEY_HKLM, "Software\\MySubKey",
                   i, keyName, &size);
// Process the key

}

(Linux) This function is not supported.

Parameters

Input
Name Type Description
rootKey unsigned int The Root Key under which you wish to access a Subkey.

See the Windows Registry functions Class help for more information about Root Keys.
subkeyName const char[] The name of the Subkey, relative to the Root Key, from which you wish to read the subkey.

See the Windows Registry functions Class help for more information about Subkeys.
index unsigned int The index of the subkey which you wish to enumerate.

This parameter should be zero for the first call to this function and then be incremented for subsequent calls.

See example in function help.
Output
Name Type Description
keyName char [] Buffer into which the name of the subkey will be stored. The buffer has to be long enough to store also the terminating NUL character.
keyNameLength unsigned int On input, use this parameter to pass the size of the buffer for the subkey name (including the terminating NUL character). On output, this parameter returns the actual length of the subkey name read from the Windows Registry (the returned number of characters does not include the terminating NUL character). This parameter may be NULL only if the parameter keyName is NULL.

Return Value

Name Type Description
status int The status code that the function returns.

0 indicates success.

A negative value indicates an error.

This function may return a Programmer's Toolbox or UI Library error code. Call GetGeneralErrorString to obtain a text description of the error.

Additional Information

Library: Programmer's Toolbox

Include file: toolbox\toolbox.h

LabWindows/CVI compatibility: LabWindows/CVI 9.0 and later