1 year ago
#383900
Itay Avraham
RegEnumValue only returning ERROR_MORE_DATA
The following code always returns error 0xEX (ERROR_MORE_DATA): According to the documentation of MSFT (https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumvaluea)
"If the function fails, the return value is a system error code. If there are no more values available, the function returns ERROR_NO_MORE_ITEMS. If the buffer specified by lpValueName or lpData is too small to receive the value, the function returns ERROR_MORE_DATA."
I set the data length to be almog 32K, what's the issue here?
#define REGISTRY_VALUE 32767
int get_key_values(HKEY* key, DWORD number_of_values)
{
DWORD values_size = REGISTRY_VALUE;
TCHAR values[REGISTRY_VALUE];
long result = ERROR_SUCCESS;
BYTE data[REGISTRY_VALUE];
DWORD data_length = REGISTRY_VALUE;
DWORD counter = 0;
for (counter = 0; counter < number_of_values; counter++) {
values_size = MAX_VALUE_NAME;
values[0] = '\0';
result = RegEnumValue(*key, counter,
values, &values_size,
NULL, NULL,
data, &data_length);
if (result == ERROR_SUCCESS) {
printf("data=%s\n", data);
} else {
return result;
}
}
}
c
windows
registry
msdn
0 Answers
Your Answer