All I'm attempting to do, is something simple; like reading an item from the registry. Now hold on there, please!.
For example: Given an registry address(\SOFTWARE\Acer\Hermes) under the domain of (HKEY_CURRENT_USER),
I've attempted to read/get an item-info under that registry address for an item. I can open the registry address ok, but to read an item, that
has been a heart wrenching experience. I've been using GetRegValue, RegQueryValueEx, and not RegenumValue - and then shuttling back and forth
between them. The end results from all these calls have been an error code of 2(two). And yes, I've been trying to follow the said rules.
And it's been a very frustrating process. From what definitions I could find out about error code two(2), MS gives it the meaning
of "FILE_NOT_FOUND". File not found???? I can open the registry with the Registry functions like: RegOpenKeyExA or RegCreateKeyExA
and have done alright. I will include the "C" code that I use. Yes, I've left past work attempts in my code, indicating different past failed attempts.
Please pardon my many frustrations. Could anyone put me back on the correct road and help get this working correctly. But Thanks in advance.
And get this 'get function's end results to leave me an error-code of zero(0)...
And Again, A Big Thanks!.
(Member 15028314)... Oh, this is not a school assignment.
What I have tried:
int GetRegStrValue(char * keyaddress, char * keypeople, char * retsname, int idlocate) {
#define SBUFFER 8192
char value[255];
DWORD BufferSize = SBUFFER;
int iretval, rv, iwhloc = 2345, iwhch = 1;
long lrv, rv1,irv;
char defaultvalue[12];
HKEY hSubKey = NULL;
char buffer[100];
DWORD DWbufsize;
strcpy(defaultvalue, "XXXXX");
#define MAX_VER_LEN 255
DWORD data_len = MAX_VER_LEN;
char new_data[MAX_VER_LEN];
iretval = 0;
lrv = RegOpenKeyExA(HKEY_CURRENT_USER, keyaddress, 0, KEY_READ | KEY_WRITE | KEY_WOW64_64KEY, &hSubKey);
if (lrv != ERROR_SUCCESS) {
lrv = RegCreateAddSetString(keyaddress, keypeople, defaultvalue, iwhch, iwhloc);
}
if (lrv == ERROR_SUCCESS) {
RegCloseKey(hSubKey); lrv = RegOpenKeyExA(HKEY_CURRENT_USER, keyaddress, 0, KEY_READ | KEY_WRITE, &hSubKey);
strcpy(buffer, "\0");
strcpy(new_data, "\0");
lrv = RegGetValue(hSubKey, NULL, (LPCWSTR)keypeople, RRF_RT_REG_SZ , NULL, (PVOID)&new_data, &data_len);
if (lrv == ERROR_SUCCESS) { RegCloseKey(hSubKey); iretval = 1;
printf(" *** GetRegStrValue, %d, <%s> \n", strlen( (char *)buffer), buffer);
}
else {
iretval = -2;
rv = ReportErrorString(lrv, idlocate);
} }
else {
iretval = -3;
rv = ReportErrorString(lrv,idlocate);
}
return(iretval);
}