?
Solved

How to use the function KeyExists ?

Posted on 1998-09-01
5
Medium Priority
?
308 Views
Last Modified: 2010-05-18
I have to use the function KeyExists to determinate if a Key
exist in the registry.
I test the function with an existing key but the function doesn't find it.
Why?????

My code:

In the interface of the unit 'fmMain':

const
   //Registry
   Cle     : String = 'Software\ANCV\Commande cheques vacance';    //sous HKEY_CURRENT_USER

The procedure using the function KeyExists:

procedure TfmMain.FormCreate(Sender: TObject);
var index              : integer;
    regHKeyCurrentUser : TRegIniFile;
begin

  regHKeyCurrentUser:=TRegIniFile.Create('HKEY_CURRENT_USER');
  if not RegHKeyCurrentUser.KeyExists(cle)
  then
    begin

The key cle exist in the registry but KeyExists return false.What's the problem ?
0
Comment
Question by:nk51
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
BlackMan earned 150 total points
ID: 1338376
Use TRegistry instead. Here's an example:

  With TRegistry.Create Do
  Begin
    RootKey := HKEY_CURRENT_USER;
    If KeyExists('SOFTWARE\Borland\DBD\7.0') Then
      ShowMessage('Key Found')
    Else
      ShowMessage('Key not found');
    Free;
  End;

0
 
LVL 1

Expert Comment

by:Edo082297
ID: 1338377
Salut nk51
  Si tu ne fais pas de changement de win3.1 je suggere d'utiliser TRegistry au lieu de TRegIniFile. De tout facon, je crois que tu as besoin de specifier le path au complet, non?

  (If you are not updating/upgrading from 3.1 I suggest using TRegistry. Anyway, don't you need to specify the whole path?).

Regards,
Edo

0
 
LVL 1

Expert Comment

by:Edo082297
ID: 1338378
Hi Blackman

You and I posted at the same time (I'm not repetitive!). Do you know why his code doesn't work?

nk51: Es-tu ABSOLUMENT certain que le string et le cle correspond?

Edo

0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1338379
I've never had great succes with TRegIniFile, so I have always used TRegistry..
0
 

Author Comment

by:nk51
ID: 1338380
Thanks, it better works with Tregistry.
Thanks to Edo too.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question