View Single Post
Old Mar 1st, 2008, 9:41 PM   #12
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4 Ancient Dragon is on a distinguished road
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;
}
__________________
<<Freelance Programmer>> << Hobby Site>>
Ancient Dragon is offline   Reply With Quote