Article View: borland.public.cppbuilder.nativeapi
Article #12025Get the path of a DLL
From: Mike Collins
Date: Mon, 29 Dec 2003 19:19
Date: Mon, 29 Dec 2003 19:19
38 lines
2992 bytes
2992 bytes
Hi all, hope everyone's had and good (and festive :-) x-mas. I've been debugging a DLL that I was working on before x-mas and I've come across and strange (but in hindsight logical) anomaly which I'm hoping someone can help me with. I traced the bug to a section of code that reads in config information from the registry. As is common with all our software, the registry keys are located under the company name with in the registry. Within that key we have the applications executable name, followed by a sub key which relates to the application version number - we do this to avoid conflicts with different versions. To ensure that the version number is always upto date and adhered to, it is check, at run-time, using the GetFileVersionInfo api. This is then concatenated together to form the registry key that we want to examine. All straight forward, no problems here!!!! Now because this is standard in our company, I wrote a couple of basic classes to deal with this. The first one, TSystemTools has a set of methods (ok everyone, don't rip me, I know it shouldn't be a class persay) to return things like the version number and the path of the current ??application?? - now this is where the problem has arisen. The method, GetAppPath(), is coded to retrieve the path of the current application / DLL based on the value of ParamStr(0) i.e. AnsiString szRtnPath = ParamStr(0); Now when I've included this class in my DLL, it seems to be returning the value of the calling application and NOT the DLL which is the thing that I need the path to, so I can pass it to my VersionInfo() method and thus retrieve the current version number of my DLL. I never really concidered that fact that a DLL doesn't really have any parameters passed to it, but I never thought it would return that value of the calling application.... I hope this makes sense - so my question is, how to I fine the path to my DLL, at run-time, when it is loaded into memory. Many, many thanks in advance, Mike C
Technical Details
Message-ID:
<3ff07bd5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2a267c1af3d1e27e,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-29 11:10:05 PST Reply-To: "Mike Collins" <mikec@kr8.co.uk> From: "Mike Collins" <mikec@kr8.co.uk> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Get the path of a DLL Date: Mon, 29 Dec 2003 19:19:37 -0000 Lines: 40 Organization: kr8 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: 81.2.78.34 Message-ID: <3ff07bd5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1072724949 81.2.78.34 (29 Dec 2003 11:09:09 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail