Article View: borland.public.cppbuilder.nativeapi
Article #8917Re: Using TRegIniFile to read REG_DWORD type
From: Remy Lebeau (TeamB)
Date: Thu, 02 Sep 2004 21:40
Date: Thu, 02 Sep 2004 21:40
33 lines
2017 bytes
2017 bytes
"Jermey" <jasonssxxx@hotmail.com> wrote in message
news:41378d59@newsgroups.borland.com...
> I verify that Count is REG_DWORD by using
> regedit. I got this message:
> raised exception class ERegistryException with message
> "Invalid data type for "Count".
Internally, TRegIniFile reads and writes values as strings only. Since the
value is actually REG_DWORD and not REG_SZ or REG_EXPAND_SZ, ReadString()
can't read it properly, thus the error.
Why are you using TRegIniFile to begin with? It should only be used for
porting legacy code that originally used TIniFile. In the code you showed,
you should use TRegistry instead:
std::auto_ptr<TRegistry> registry(new TRegistry);
registry->RootKey = HKEY_LOCAL_MACHINE;
int value = 0;
if(
registry->OpenKeyReadOnly("SYSTEM\\CurrentControlSet\\Services\\XXXXXX\\Enum
") )
{
if( registry->ValueExists("Count" ) )
value = registry->ReadInteger("Count");
registry->CloseKey();
}
Gambit
Technical Details
Message-ID:
<41379300$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!colt.net!easynet-monga!easynews.net!easynet-isham!easynet.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<41376ce0$1@newsgroups.borland.com> <413777c5$1@newsgroups.borland.com> <41378d59@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,29fe9a1bf7a007b8 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <41376ce0$1@newsgroups.borland.com> <413777c5$1@newsgroups.borland.com> <41378d59@newsgroups.borland.com> Subject: Re: Using TRegIniFile to read REG_DWORD type Date: Thu, 2 Sep 2004 14:40:41 -0700 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41379300$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1094161152 68.69.17.41 (2 Sep 2004 14:39:12 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!colt.net!easynet-monga!easynews.net!easynet-isham!easynet.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail