HELP! RegQueryValueEx fails with 0xC00000005

  • Thread starter Thread starter Michael Vidrevich
  • Start date Start date
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 used almost the same code and no errors occuried (Windows XP English). My program reads this value (though it very long).

Error code 0xC0000005 has'nt enumerated in winerror.h, and no appropriate ERROR_* constant defined. May be the error occurs in some another place (after RegQueryValueEx)?

Unfortunately, I can not mind out an another answer on your question.

--
Loskutov Eugene
http://www.regwrks.com
 
I used almost the same code and no errors occuried (Windows XP English). My program reads this value (though it very long).

Error code 0xC0000005 has'nt enumerated in winerror.h, and no appropriate ERROR_* constant defined. May be the error occurs in some another place (after RegQueryValueEx)?

Unfortunately, I can not mind out an another answer on your question.

--
Loskutov Eugene
http://www.regwrks.com
 
Thank you for your help.

Best Regards,
Michael.

Loskutov Eugene said:
I used almost the same code and no errors occuried (Windows XP English).
My program reads this value (though it very long).
Error code 0xC0000005 has'nt enumerated in winerror.h, and no
appropriate ERROR_* constant defined. May be the error occurs in some
another place (after RegQueryValueEx)?
 
Thank you for your help.

Best Regards,
Michael.

Loskutov Eugene said:
I used almost the same code and no errors occuried (Windows XP English).
My program reads this value (though it very long).
Error code 0xC0000005 has'nt enumerated in winerror.h, and no
appropriate ERROR_* constant defined. May be the error occurs in some
another place (after RegQueryValueEx)?
 
Back
Top