Do you have a problem with this code? Or are yoy just presenting a useful fact for future use?
Andy
PS Note that (a) RegQueryValueEx returns a LONG value, and (b) RegQueryValueEx maps to either RegQueryValueExA or RegQueryValueExW depending on whether or not UNICODE is #defined. So the ANSI version would be better written as:
1 2 3 4 5 6 7 8 9 10 11 12 13
//Assume hKey contains a valid HKEY obtained from calling RegOpenKeyEx(...)
LONG result = RegQueryValueExA(hKey, "somevaluename", NULL, NULL, NULL, NULL);
if (result == ERROR_SUCCESS) {
printf("Found\r\n");
}
elseif (result == ERROR_FILE_NOT_FOUND) {
printf("Not found\r\n");
}
else {
printf("There was an error\r\n");
}