1 Replies - 1450 Views - Last Post: 05 November 2001 - 08:50 AM Rate Topic: -----

#1 Zanthor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-November 01

Registry Reading Problems - Win32

Posted 04 November 2001 - 01:05 PM

Hiya folks, I'm having difficulties reading registry keys for a
program I'm writing.  What I'm doing is loading filenames into
variables, in this case all the filenames are .wav's

// Open Registry
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWAREOGCANTradeHelper", 0,
KEY_QUERY_VALUE, &hKey);

// Get the string and store it in CamDir
if (RegQueryValueEx(hKey, "CamelotDirectory", NULL, NULL, (LPBYTE)
CamDir, &dwBufLen)){
    // Display error on fail.
    MessageBox( NULL, "CamDir", "TradeHelper v1.5", MB_OK );
}
// When reading multiple keys I just copy and paste the above
// code and change the relevant bits... I'm not closing between each
read.

// Close Registry
RegCloseKey(hKey);

Ok, this works fine, BUT when I try to get all 23 of the values I
need, it fails on some... For example it failed on the 8th, 18th and
20th keys...  So I shuffle things around, move 4 keys to the end of
the list... and then it fails on the 4th, 14th, 17th, and 20th.
Depending how I move things, I can get all keys to succeed or fail,
but can't figure out WHY this is happening...

I've fought with this for a whil enow and can't figure out whats going
on... any help would be much appreciated :)


Is This A Good Question/Topic? 0
  • +

Replies To: Registry Reading Problems - Win32

#2 Zanthor  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-November 01

Re: Registry Reading Problems - Win32

Posted 05 November 2001 - 08:50 AM

Someone replied to my query on Usenet... Thought I'd share it here.  Apparently My noobness got the best of me, time to rework the way I handle this!

>
> dwBufLen is updated with the length of the returned registry value IIRC, and
> I can see how that would cause the problem you are seeing.
>
> HTH,
> Alex

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1