HELP! RegQueryValueEx fails with 0xC00000005

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
 
L

Loskutov Eugene

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
 
L

Loskutov Eugene

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
 
M

Michael Vidrevich

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)?
 
M

Michael Vidrevich

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)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top