View Single Post
Old Mar 1st, 2008, 6:28 PM   #6
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 changed your program to call RegQueryKeyEx() and it works now
cplusplus Syntax (Toggle Plain Text)
  1. int main(int argc, char *argv[])
  2. {
  3. HKEY MyKey = 0;
  4.  
  5. BYTE szBuff[255] = {0};
  6. DWORD cb = 0;
  7. DWORD dwType = REG_SZ;
  8. LONG rval;
  9. if (RegOpenKey(HKEY_CURRENT_USER, "Software\\Random\\Program", &MyKey) == ERROR_SUCCESS)
  10. {
  11. cout << "Program is installed\n";
  12. cb = sizeof(szBuff);
  13.  
  14. //Debug info, this normally isn't here!
  15.  
  16. if((rval = RegQueryValueEx(MyKey, "hexData", 0, &dwType, szBuff, &cb)) == ERROR_SUCCESS)
  17. {
  18. cout << "Program has been run once\n";
  19. printf((char *)szBuff);
  20. }
  21. printf("%d",rval);
  22. cout << '\n';
  23.  
  24. RegCloseKey(MyKey);
  25. }
  26.  
  27. system("PAUSE");
  28. return EXIT_SUCCESS;
  29. }
And the output is
Quote:
Program is installed
Program has been run once
0611623CA8EFE3D880FF72E0F9A5AACDE5D9C171EAE2C6FDB6888BF7B5386DEE0
Press any key to continue . . .
__________________
<<Freelance Programmer>> << Hobby Site>>
Ancient Dragon is offline   Reply With Quote