🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15736

Re: RegQueryValueEx problem

#15736
From: Remy Lebeau (TeamB)
Date: Tue, 17 Jun 2003 18:31
26 lines
2030 bytes
"robertbienert<AT>gmx.net gmx.net >" <"robertbienert<AT> wrote in message
news:3eef5413@newsgroups.borland.com...

> has anyone a RegQuery-example? I've got problems
> executing the following code: The result shows me, that
> the program cannot find the specified registry key, but
> it is there, as regedit shows to me. I'm thankful for any help!

You should not be reading the "Shell Folders" manually.  MS has a separate
SHGetSpecialFolderLocation() function for exactly that purpose instead.  Use
the CSIDL_PERSONAL flag to request the value you're trying to get.

> if(RegQueryValueEx(regh, regkey, NULL, NULL, buffer, buffsize + 1) ==
ERROR_SUCCESS) {

Where is buffer and bufsize defined?  They are not in your code snippet at
all.  What are they defined as exactly?  What is the actual return value of
RegQueryValueEx() when it fails?  What is the return value of
GetLastError()?

Also, you have a resource leak as you are calling RegCloseKey() only if
RegQueryKeyEx() succeeds.  If it fails, you are not closing the key at all.


Gambit
Technical Details
Message-ID: <3eef5db8$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3eef5413@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,5800567a1464c960
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-17 11:32:46 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3eef5413@newsgroups.borland.com>
Subject: Re: RegQueryValueEx problem
Date: Tue, 17 Jun 2003 11:31:56 -0700
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3eef5db8$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1055874488 207.175.226.26 (17 Jun 2003 11:28:08 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail