![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: Mar 2008
Posts: 25
Rep Power: 0
![]() |
Re: RegQueryValue Issues
Ok, I am a little lost on this one now. I never liked MSDN...so for example lets say we have two values. One is named hexData and then the other is stringData, and we want to read them into hexBuff and the other one into stringBuff. How would i put that into this. It would use MyKey and then the first one will be 0 and the second one will be 1 for the next value. And after that I get lost to how they want to go about doing the rest, any help Ancient Dragon? Also thank you alot for the help so far, and sorry for the slowness on this.
|
|
|
|
|
|
#12 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 499
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;
}
__________________
I Like Ike. Vote for Dwight Eisenhower this November. --This message brought to you by the the Procrastinators Club Of America. |
|
|
|
|
|
#13 |
|
Newbie
Join Date: Mar 2008
Posts: 25
Rep Power: 0
![]() |
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)
Windows is installed!(Duh!) ParseAutoexec : 1 Error - 234 Press any key to continue . . . |
|
|
|
|
|
#14 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 499
Rep Power: 4
![]() |
Re: RegQueryValue Issues
>>Also the constant resizing of the buffsizes value is pointless being that they never change through out this
That's needed because RegEnumValue() changes the variable to the actual length of the text inserted into the destination buffer (the string may or may not be null-terminated). So you have to change it back to the original value before calling RegEnumValue() again. Quote:
__________________
I Like Ike. Vote for Dwight Eisenhower this November. --This message brought to you by the the Procrastinators Club Of America. |
|
|
|
|
|
|
#15 |
|
Newbie
Join Date: Mar 2008
Posts: 25
Rep Power: 0
![]() |
Re: RegQueryValue Issues
Alrighty then, at first adding that first resize doesn't make it work. However there was a secondary one that was needed.
c++ Syntax (Toggle Plain Text)
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| LWP form Data array issues | Johnmcter | Perl | 0 | Feb 13th, 2008 2:21 PM |
| Intermittent issues | blud | Community Announcements and Feedback | 3 | Nov 2nd, 2007 8:46 AM |
| Table issues... | Glastea | HTML / XHTML / CSS | 2 | Jan 12th, 2007 1:54 AM |
| I have an idea, but copyright issues. | Booooze | Project Ideas | 25 | Aug 3rd, 2006 9:31 PM |