[fpc-pascal]TRegistry unit not functional on win32?

Ronald L Fox rfox at dls.queens.org
Wed Jul 9 07:56:35 CEST 2003


Aloha,

I'm trying to use the TRegistry object of fpc 1.0.6 for Win32 on Win2k
to check for the presence of a particular key, 
'HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys' and value
name 'rsa at 22:ahost.ourdomain.com'.

I've studied the Registry unit's source from \source\fcl\inc\registry.pp
and the Borland Delphi 2.0 VCL help file but can't get anything but lies
from my code.

A simple test program and runtime output below illustrates the problem.
No matter what I enter, the program indicates that the key exists and that
it has no subkeys and no values.  Since the keys are supposed to be relative
to the base or root key, I know that there is no "nada" key but that there
is a "Software" key with many subkeys and values.

Is this unit supposed to be functional?  Any idea how I can perform this
simple existence test if Registry isn't functional?

BTW, I am so stoked to be programming in Pascal again!

Mahalo,
Ron
--------------------------
program regquery;

uses
   Registry;

var
   myTRO        : TRegistry;
   myKeyInfo    : TRegKeyInfo;
   myKey,
   response     : String;

begin

myTRO := TRegistry.Create;

repeat
   write('Enter Key: ');
   readln(myKey);
   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('Key doesn''t exist');

   write('Continue? ');
   readln(response);
until response = 'n';

myTRO.Free;
end.
--------------------------------------------------------------------------------
C:\my-fpc\testing\registry>regquery
Enter Key: Software
NumSubKeys: 0
NumValues : 0
Continue? y

Enter Key:
NumSubKeys: 0
NumValues : 0
Continue? n

C:\my-fpc\testing\registry>regquery
Enter Key: nada
NumSubKeys: 0
NumValues : 0
Continue? n

C:\my-fpc\testing\registry>


-- 
Ronald L Fox                               Email: rfox at dls.queens.org
Diagnostic Laboratory Services, Inc.
Honolulu, Hawaii
-- 
Ronald L Fox                               Email: rfox at dls.queens.org
Diagnostic Laboratory Services, Inc.
Honolulu, Hawaii





More information about the fpc-pascal mailing list