View Single Post
Old Mar 1st, 2008, 9:40 PM   #13
KuraKai
Newbie
 
Join Date: Mar 2008
Posts: 25
Rep Power: 0 KuraKai is on a distinguished road
Re: RegQueryValue Issues

Ok I cleaned up the code a bit, this is only to list every values in the key.
C++ Syntax (Toggle Plain Text)
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include "windows.h"
  4. #include "winnt.h"
  5. #include "winreg.h"
  6.  
  7.  
  8. using namespace std;
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. HKEY myKey = 0;
  13.  
  14. char szValueBuff[255] = {0};
  15. char szValueName[255] = {0};
  16.  
  17. DWORD dwType = REG_SZ;
  18.  
  19. if(RegOpenKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", &myKey) == ERROR_SUCCESS)
  20. {
  21. cout << "Windows is installed!(Duh!)\n";
  22.  
  23. DWORD index = 0;
  24. DWORD dwValueNameSize = sizeof(szValueName);
  25. DWORD dwValueBuffSize = sizeof(szValueBuff);
  26. while(RegEnumValue(myKey, index, szValueName, &dwValueNameSize, 0,
  27. &dwType, (byte *)szValueBuff, &dwValueBuffSize) == ERROR_SUCCESS)
  28. {
  29. cout << szValueName << " : " << szValueBuff << "\n";
  30. index++;
  31. }
  32.  
  33. cout << "Error - ";
  34. cout << RegEnumValue(myKey, index, szValueName, &dwValueNameSize, 0,
  35. &dwType, (byte *)szValueBuff, &dwValueBuffSize);
  36. cout << '\n';
  37.  
  38. RegCloseKey(myKey);
  39. }
  40.  
  41. system("PAUSE");
  42. return EXIT_SUCCESS;
  43. }
This for me returns...
Windows is installed!(Duh!)
ParseAutoexec : 1
Error - 234
Press any key to continue . . .
But there are other values there that aren't being found. Also the constant resizing of the buffsizes value is pointless being that they never change through out this.
KuraKai is offline   Reply With Quote