🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: what's wrong with this code?

#13870
From: Remy Lebeau (TeamB)
Date: Sun, 14 Sep 2003 06:04
42 lines
2352 bytes
"FrankW" <nospam@nospam.com> wrote in message
news:3f63f54e@newsgroups.borland.com...

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

It will create the key itself, if you have the CanCreate parameter set to
true.  However, that does not mean that the "MainApp" value will always
exist inside the key, especially if the key is being created anew.  You have
to test for that separately, ie:

    void __fastcall GetParam(int &MainApp)
    {
        MainApp = 0;

        TRegistry *Reg = NULL;
        try
        {
            Reg = new TRegistry;
            Reg->RootKey = HKEY_CURRENT_USER;

            if( Reg->OpenKey("Software\\Microsoft\\Internet Explorer",
true) )
            {
                if( Reg->ValueExists("MainApp") )
                    MainApp = Reg -> ReadInteger("MainApp");
            }
        }
        catch(Exception&) {}
        delete Reg;
    }


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: <3f6404d7$1@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-05!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
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> <3f63f54e@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 23:06:13 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.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> <3f63f54e@newsgroups.borland.com>
Subject: Re: what's wrong with this code?
Date: Sat, 13 Sep 2003 23:04:57 -0700
Lines: 44
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: 207.175.226.26
Message-ID: <3f6404d7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1063519447 207.175.226.26 (13 Sep 2003 23:04:07 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-05!sn-xit-09!supernews.com!newsfeed.news2me.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail