RegGetValue vs RegQueryValueEx
Posted
by baltusaj
on Stack Overflow
See other posts from Stack Overflow
or by baltusaj
Published on 2010-05-13T10:59:47Z
Indexed on
2010/05/13
11:04 UTC
Read the original article
Hit count: 2128
Windows
I have a program coded by someone else. It has a function RegGetValue used as:
uFuncReturnValue = RegOpenKeyExA( HKEY_LOCAL_MACHINE,
acSubKey,
NULL,
KEY_READ | KEY_WRITE,
&hRegistry
);
if( uFuncReturnValue != ERROR_SUCCESS )
{
printf("Unable to open registry with error %u\n", uFuncReturnValue);
exit(EXIT_FAILURE);;
}
uFuncReturnValue = RegGetValueA( hRegistry,
NULL,
"\\DosDevices\\C:",
RRF_RT_REG_BINARY,
NULL,
(LPVOID)&structVal,
&dwSize
);
This block of code works perfectly on Windows 7 but returns error when run on Windows XP (32 bit). As 32-bit xp don't have RegGetValue function so I am trying to make use of RegQueryValueEX but I am having problem in passing arguments to this function. I think it should be used some thing like:
uFuncReturnValue = RegQueryValueExA ( hRegistry,
"\\DosDevices\\J:",
NULL,
NULL,
(LPBYTE) &structVal,
&dwSize
);
But something is wrong here because the code compiles successfully but when I execute it I get a message:
The program '(128) myProgram.exe: Native' has exited with code 1 (0x1).
Can someone help me here please?
© Stack Overflow or respective owner