🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: RegQueryValueEx problem

#15588
From: robertbienert gmx.net robertbien...
Date: Fri, 20 Jun 2003 21:17
40 lines
3218 bytes
Remy Lebeau (TeamB) wrote:
> C++Builder comes with its own copy of the Win32 help files, and you can
> always just look everything up at MSDN online directly.

I've got only the free command line tools because I'm a poor student who 
learns C for selling programms, so that I'll have enough money to buy 
the Builder.

> You didn't include the EXE's actual code at all.  You are not showing how
> you are actually allocating the buffer that you want your DLL function to
> fill in.  You're allowing any arbitrary buffer to be passed in from the EXE,
> but the DLL is assuming its own buffer size instead of allowing the EXE to
> tell the DLL exactly what the buffer size really is.

I think I found the mistake. In my exe, buffer was defined under the 
name lpPersonal as char*, but I set no explicit size. I came to this, 
because of your hint and the fact, that the program always crashed when 
I tried to access the buffer inside the exe. Inside the DLL, I'm able to 
show the buffer as MessageBox text.

> In fact, looking over this code, you are not assigning any kind of actual
> value to your buffer size in the first place.  You declared your buffer size
> as a pointer that you never actually assign to point to anywhere meaningful.
> As such, you're going to have any sort of potential problems when you are
> using the value later on because it is not valid to begin with.
> 
> I would suggest the simpler of the two possible solutions - just get rid of
> your buffer size variable from the DLL altogether and let the function
> accept an additional parameter so the EXE call specifically tell the DLL
> exactly what the buffer size already is:
> 
>     int __stdcall getShellFolder(int folder, char *buffer, DWORD buffersize)

What can the DLL to with this third parameter? It can see, that the 
buffer maybe to small.

Yours,
-- 
Robert Bienert <robertbienert@gmx.net>
Check also my free software at http://www.rbprogs.de.vu/
Technical Details
Message-ID: <3ef379f4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3eef5413@newsgroups.borland.com> <3eef5db8$1@newsgroups.borland.com> <3ef0879a$1@newsgroups.borland.com> <3ef09c68@newsgroups.borland.com> <3ef0da0c@newsgroups.borland.com> <3ef0de90@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-20 14:51:41 PST
Date: Fri, 20 Jun 2003 23:17:12 +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> <3ef0879a$1@newsgroups.borland.com> <3ef09c68@newsgroups.borland.com> <3ef0da0c@newsgroups.borland.com> <3ef0de90@newsgroups.borland.com>
In-Reply-To: <3ef0de90@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 195.127.134.155
Message-ID: <3ef379f4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1056143860 195.127.134.155 (20 Jun 2003 14:17:40 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail