🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: RegQueryValueEx problem

#15757
From: robertbienert gmx.net robertbien...
Date: Wed, 18 Jun 2003 15:38
27 lines
2288 bytes
Remy Lebeau (TeamB) wrote:
> 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.

Have you got an example for this?

>>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()?

buffer comes from the calling exe (this is a snipet from a dll) and is 
type char* or LPCSTR (or so). Buffsize is its size + 1 byte for the 
terminating null.

> 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.

If I call RegCloseKey when RegQueryEx failed, I got an acces violation.
-- 
Robert Bienert <robertbienert@gmx.net>
Check also my free software at http://www.rbprogs.de.vu/
Technical Details
Message-ID: <3ef0879a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3eef5413@newsgroups.borland.com> <3eef5db8$1@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-18 08:43:53 PST
Date: Wed, 18 Jun 2003 17:38:34 +0200
From: "robertbienert<AT>gmx.net" <"robertbienert<AT>gmx.net">
User-Agent: Mozilla/5.0 (Windows; U; Win98; de-AT; rv:1.2) Gecko/20021126
X-Accept-Language: de, en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: RegQueryValueEx problem
References: <3eef5413@newsgroups.borland.com> <3eef5db8$1@newsgroups.borland.com>
In-Reply-To: <3eef5db8$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 195.127.134.201
Message-ID: <3ef0879a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1055950746 195.127.134.201 (18 Jun 2003 08:39:06 -0700)
Lines: 28
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail