M
Michael Vidrevich
Environment: Windows XP Japanese.
I call RegQueryValueEx for REG_MULTI_SZ value as following:
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\Perflib\\011", 0, KEY_READ, &hKey);
if (res != ERROR_SUCCESS)
{
printf("Open registry key failed!\r\n");
return res;
}
res = RegQueryValueEx(hKey, "Counter", NULL, &dwType, NULL, &numChars);
if (res != ERROR_SUCCESS)
{
printf("First: Query Multi String Value failed!\r\n");
return res;
}
BYTE* buff = (BYTE*) malloc(numChars);
if (NULL == buff)
{
printf("Out of MEMORY: Allocation failed!\r\n");
return -1;
}
res = RegQueryValueEx(hKey, "Counter", NULL, &dwType, buff, &numChars);
if (res != ERROR_SUCCESS)
{
printf("Second: Query Multi String Value failed!\r\n");
return res;
}
By MSDN help numChars after first call contains data size in bytes.
Actually, it contains size in Chars.
By MSDN help function returns ERROR_MORE_DATA if buffer is too small.
Actually, second call returns 0xC00000005 (This is catched exception "Access
violation" I think but I am not sure).
Can somebody explain it?
Thanks in advance.
Michael
I call RegQueryValueEx for REG_MULTI_SZ value as following:
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows
NT\\CurrentVersion\\Perflib\\011", 0, KEY_READ, &hKey);
if (res != ERROR_SUCCESS)
{
printf("Open registry key failed!\r\n");
return res;
}
res = RegQueryValueEx(hKey, "Counter", NULL, &dwType, NULL, &numChars);
if (res != ERROR_SUCCESS)
{
printf("First: Query Multi String Value failed!\r\n");
return res;
}
BYTE* buff = (BYTE*) malloc(numChars);
if (NULL == buff)
{
printf("Out of MEMORY: Allocation failed!\r\n");
return -1;
}
res = RegQueryValueEx(hKey, "Counter", NULL, &dwType, buff, &numChars);
if (res != ERROR_SUCCESS)
{
printf("Second: Query Multi String Value failed!\r\n");
return res;
}
By MSDN help numChars after first call contains data size in bytes.
Actually, it contains size in Chars.
By MSDN help function returns ERROR_MORE_DATA if buffer is too small.
Actually, second call returns 0xC00000005 (This is catched exception "Access
violation" I think but I am not sure).
Can somebody explain it?
Thanks in advance.
Michael