Article View: borland.public.cppbuilder.nativeapi
Article #13869Re: what's wrong with this code?
From: FrankW
Date: Sun, 14 Sep 2003 04:56
Date: Sun, 14 Sep 2003 04:56
65 lines
2680 bytes
2680 bytes
Hi Remy,
Here is the code that will cause an AV if the integer "MainApp" not exist, I
was hoping OpenKey will create the key if it does not exist.
Frank
void __fastcall GetParam(int &MainApp)
{
MainApp = 0;
TRegistry *Reg = new TRegistry;
try
{
Reg->RootKey = HKEY_CURRENT_USER;
if (Reg->OpenKey("Software\\Microsoft\\Internet Explorer", true))
{
MainApp = Reg -> ReadInteger("MainApp");
}
}
__finally
{
Reg->CloseKey();
delete Reg;
}
}
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
int MainApp;
GetParam(MainApp);
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3f63f0fd$1@newsgroups.borland.com...
> > I can't use TRegistry approach as i need to access
> > the registry before Application->Initialize();
>
> Of course you can use TRegistry before Application->Initialize().
TRegistry
> has no dependancies on TApplication at all. Simply modify the project's
> WinMain() function directly if you want to do anything before initializing
> TApplication.
>
>
> Gambit
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
>
>
Technical Details
Message-ID:
<3f63f54e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f63ddac@newsgroups.borland.com> <3f63df78$1@newsgroups.borland.com> <3f63e14b@newsgroups.borland.com> <3f63e3c0$1@newsgroups.borland.com> <3f63e876$1@newsgroups.borland.com> <3f63f0fd$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,636b723329c7c5e8 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-13 22:01:07 PST Reply-To: "FrankW" <nospam@nospam.com> From: "FrankW" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f63ddac@newsgroups.borland.com> <3f63df78$1@newsgroups.borland.com> <3f63e14b@newsgroups.borland.com> <3f63e3c0$1@newsgroups.borland.com> <3f63e876$1@newsgroups.borland.com> <3f63f0fd$1@newsgroups.borland.com> Subject: Re: what's wrong with this code? Date: Sun, 14 Sep 2003 12:56:37 +0800 Lines: 67 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: 203.131.162.116 Message-ID: <3f63f54e@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1063515470 203.131.162.116 (13 Sep 2003 21:57:50 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail