Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-07

TRegistry unit not functional on win32?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ronald L Fox

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 ''.

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: Diagnostic Laboratory Services, Inc. Honolulu, Hawaii -- Ronald L Fox Email: Diagnostic Laboratory Services, Inc. Honolulu, Hawaii

Reply by email

Michael Van Canneyt
to Ronald L Fox: I'm trying to use the TRegistry object of fpc 1.0.6 for Win32 on Win2k to check for the…
Ronald L Fox wrote 19 lines
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 ''. 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?

The official 1.0.6 release didn't contain a functional registry unit. However, the latest sources do contain a version that works on Windows and on Linux. You can always download the latest sources and compile the unit yourself.

Michael.

Reply by email