Link to home
Start Free TrialLog in
Avatar of nk51
nk51

asked on

How to use the function KeyExists ?

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 ?
ASKER CERTIFIED SOLUTION
Avatar of BlackMan
BlackMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Edo082297
Edo082297

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

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

I've never had great succes with TRegIniFile, so I have always used TRegistry..
Avatar of nk51

ASKER

Thanks, it better works with Tregistry.
Thanks to Edo too.