Article View: borland.public.cppbuilder.nativeapi
Article #17617Re: How to get application's directory?
From: Remy Lebeau (TeamB)
Date: Mon, 24 Mar 2003 01:57
Date: Mon, 24 Mar 2003 01:57
44 lines
2887 bytes
2887 bytes
"Rodolfo Frino - Stargate Software" <starcinema@eftel.com> wrote in message
news:3e7e5a97@newsgroups.borland.com...
> The global variable ApplicationDirectory will get you the
> applications directory, even if you use TOpenDialog or any
> other Win3.1 component from the component palette.
You have not paid much attenttion to anything that has been said before.
You **cannot** rely on that approach, as there are several external factors
that can alter the process's current working directly *on startup* before
your code ever gets a chance to start running. Parsing the
TApplication::ExeName property (which uses GetModuleFileName() internally)
is the *only* reliable way to get the application's actual installation
directory regardless of what the process's current working directly is set
to, whether manually, implicitially via component, or by the OS itself.
Also, just as an unrelated side note, if you want to inject your own startup
code into the TApplication startup process, the official ways is to assign a
function pointer to the global InitProc variable, not replacing the calling
of TApplication::Initialize() itself with your own calling.
TApplication::Initialize() calls InitProc() internally if it is assigned an
actual function pointer:
TProcedure OldInitProc;
void __fastcall MyInitialize(void)
{
...
if( OldInitProc ) OldInitProc();
}
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
OldInitProc = InitProc;
InitProc = MyInitialize;
Application->Initialize()
...
Gambit
Technical Details
Message-ID:
<3e7e63ae$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e7a7800$1@newsgroups.borland.com> <3e7a8e39@newsgroups.borland.com> <3e7ae7af$1@newsgroups.borland.com> <3e7c7c8c@newsgroups.borland.com> <3e7cc472$1@newsgroups.borland.com> <3e7cd82a@newsgroups.borland.com> <3e7cfd40$1@newsgroups.borland.com> <3e7dba28@newsgroups.borland.com> <3e7e28c5$1@newsgroups.borland.com> <3e7e5a97@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,440cb76ba9be739c X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-24 00:24:22 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3e7a7800$1@newsgroups.borland.com> <3e7a8e39@newsgroups.borland.com> <3e7ae7af$1@newsgroups.borland.com> <3e7c7c8c@newsgroups.borland.com> <3e7cc472$1@newsgroups.borland.com> <3e7cd82a@newsgroups.borland.com> <3e7cfd40$1@newsgroups.borland.com> <3e7dba28@newsgroups.borland.com> <3e7e28c5$1@newsgroups.borland.com> <3e7e5a97@newsgroups.borland.com> Subject: Re: How to get application's directory? Date: Sun, 23 Mar 2003 17:57:09 -0800 Lines: 46 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3e7e63ae$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1048470446 207.175.226.26 (23 Mar 2003 17:47:26 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail