[fpc-pascal]v1.0.10 w32 release TRegistry.KeyExists function broken?
    Ronald Fox 
    rfox at dls.queens.org
       
    Mon Jul 14 02:10:23 CEST 2003
    
    
  
I'm very happy to see a working Registry unit for win32 in the
latest release.  I can't get the KeyExists function to work as
I imagine it should, though.  I would expect that KeyExists
should test for the presence of a relative or absolute key in the
registry.  Instead, it seems to return false for any supplied key
until there is a successful OpenKey on any key, then it will return
true for any key, even non-existant keys.
On an unrelated note, should the 2 Hints that appear in the compiler
output be showing up?  They didn't in my v1.0.6 install.
Thanks to all who work so tirelessly on this project, your efforts
are greatly appreciated.
Regards,
Ron
----------------------
program regquery;
uses
  Registry;
var
  myTRO        : TRegistry;
  myKeyInfo    : TRegKeyInfo;
  myKey        : String;
begin
myTRO := TRegistry.Create;
myTRO.RootKey := HKEY_CURRENT_USER;
repeat
  write('Enter Key: ');
  readln(myKey);
  if myKey <> ''
    then
      begin
      if myTRO.KeyExists(myKey)
        then writeln('Key exists.')
        else writeln('Key doesn''t exist.');
    
      if myTRO.OpenKey(myKey,False)
        then
          begin
          if myTRO.GetKeyInfo(myKeyInfo)
            then
              begin
              writeln('NumSubKeys: ',myKeyInfo.NumSubKeys);
              writeln('NumValues : ',myKeyInfo.NumValues);
              end;
          end
        else writeln('Can''t open key.');
      writeln;
      end;
until myKey = '';
myTRO.Free;
end.
-------------------------------
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>cd my-fpc\testing\registry
C:\my-fpc\testing\registry>ppc386 regquery.pp
Hint: End of reading config file c:\pp\bin\win32\fpc.cfg
Free Pascal Compiler version 1.0.10 [2003/06/27] for i386
Copyright (c) 1993-2003 by Florian Klaempfl
Target OS: Win32 for i386
Compiling regquery.pp
syswin32.pp(3,1) Hint: Conditional I386 was set at startup in last compilation of syswin32.pp
Linking regquery.exe
42 Lines compiled, 4.2 sec
C:\my-fpc\testing\registry>regquery.exe
Enter Key: nada
Key doesn't exist.
Can't open key.
Enter Key: nada
Key doesn't exist.
Can't open key.
Enter Key: \Software
Key doesn't exist.
NumSubKeys: 16
NumValues : 0
Enter Key: \Software
Key exists.
NumSubKeys: 16
NumValues : 0
Enter Key: nada
Key exists.
Can't open key.
Enter Key: nada
Key exists.
Can't open key.
Enter Key: \Software
Key exists.
NumSubKeys: 16
NumValues : 0
Enter Key: \nada
Key exists.
Can't open key.
Enter Key:
C:\my-fpc\testing\registry>
-- 
Ronald Fox                                Email: rfox at dls.queens.org
Diagnostic Laboratory Services, Inc.      Phone: (808) 589-5172
Honolulu, Hawaii
    
    
More information about the fpc-pascal
mailing list