|
PFO God In Training
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4 
|
Re: RegQueryValue Issues
I have deleted the test data in my registry but I think this will work
int main(int argc, char *argv[])
{
HKEY MyKey = 0;
BYTE szBuff[255] = {0};
char szStringBuff[255] = {0};
char szValueName[255] = {0};
DWORD cb = 0;
DWORD dwType = REG_SZ;
LONG rval;
if (RegOpenKey(HKEY_CURRENT_USER, "Software\\Random\\Program", &MyKey) == ERROR_SUCCESS)
{
cout << "Program is installed\n";
cb = sizeof(szBuff);
//Debug info, this normally isn't here!
DWORD index = 0;
DWORD dwValueNameSize = sizeof(szValueName);
rval = RegEnumValue(MyKey, index, szValueName, &dwValueNameSize, 0, &dwType, szBuff, &cb);
while(rval == ERROR_SUCCESS)
{
cout << szValueName << ": " << szBuff << "\n";
// sqValueName is the name of the key
if( stricmp(szValueName,"hexBuff") == 0)
strcpy((char *)szBuff, szValueName);
else if( stricmp(szValueName, "stringBuff") == 0)
strcpy(szStringBuff, szValueName);
// increment index counter to get next key
index++;
dwValueNameSize = sizeof(szValueName);
rval = RegEnumValue(MyKey, index, szValueName, &dwValueNameSize, 0, &dwType, szBuff, &cb);
}
printf("%d",rval);
cout << '\n';
RegCloseKey(MyKey);
}
system("PAUSE");
return EXIT_SUCCESS;
}
|