Article View: borland.public.cppbuilder.nativeapi
Article #12289Re: FirstTimeWindowsInstalled.
From: Remy Lebeau (TeamB)
Date: Sun, 14 Dec 2003 22:06
Date: Sun, 14 Dec 2003 22:06
43 lines
2386 bytes
2386 bytes
"Safari" <Safari@alloymail.com> wrote in message
news:3fdc4d66@newsgroups.borland.com...
> How can i read FirstTimeWindowsInstalled from Registry?
You already know how, because you showed the code for doing that. So what
is the actual problem?
> TRegistry *Regis = new TRegistry.Create;
That is not the correct way to instantiate TRegistry (or any other class,
for that matter). You must have a Delphi background, because you keep
trying to post Delphi code lately in your C++ questions. The correct way to
instantiate TRegistry in this example should be the following instead:
TRegistry *Regis = new TRegistry;
> Regis->RootKey = HKEY_LOCAL_MACHINE;
Which version of BCB are you using? If BCB 5 or 6, then since you are
trying to access the HKLM key under an NT-based system, you should set the
TRegistry's Access property to KEY_READ because of security restrictions on
the HKLM key:
Regis->Access = KEY_READ;
Alternatively, you can call OpenKeyReadOnly() instead of OpenKey() to get
the same effect.
> Regis->OpenKey("\\Software\\Microsoft\\Windows NT\\CurrentVersion",
> false);
OpenKey() (and OpenKeyReadOnly()) has a boolean return value that you should
be testing before you call ReadInteger(), otherwise you are going to get an
exception from trying to read a value from an unopened key:
if( Regis->OpenKey("\\Software\\Microsoft\\Windows NT\\CurrentVersion",
false) )
//...
Gambit
Technical Details
Message-ID:
<3fdcddd4$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!skynet.be!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fdc4d66@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,4bc4a0b3c60109c0 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-14 14:08:42 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fdc4d66@newsgroups.borland.com> Subject: Re: FirstTimeWindowsInstalled. Date: Sun, 14 Dec 2003 14:06:34 -0800 Lines: 45 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: 67.23.78.224 Message-ID: <3fdcddd4$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071439316 67.23.78.224 (14 Dec 2003 14:01:56 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!skynet.be!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail