[lazarus] The registry is alive

Curtis White cwhite at aracnet.com
Fri Nov 10 21:59:03 EST 2000


With the rest of the Lazarus components, we didn't use {$IFDEF WIN32}
clauses. That was part of making the component set platform independent.
If you need to write some platform specific code, then it should be
implemented the same way as the other components.

I haven't done anything with all this for quite a while now, so I don't
remember how we were doing it. But I believe there is a how-to on the
Lazarus site that explains how to implement platform specific code in
the components.

I also agree that it is better to use the TRegistry component in the FCL
and to implement a Linux version of it.


Curtis


"Luis R. Hilario B." wrote:

> The changes and new things:
>
> registry.inc
> ============
>
> function TRegistry.DeleteKey(const Key: String): Boolean;
> Var
>   Val : LongInt;
>   KeyP: PChar;
>
> begin
>   KeyP := @Key[1];
>
> {$IFDEF WIN32}
>   Val  := RegDeleteKey(fRootKey, KeyP);
> {$ELSE}
>   Val := 1;
>   //  Val := XMLRegDeleteKey(fRootKey, KeyP); ???
> {$ENDIF}
>   If Val = 0 Then Result := True else Result := False;
>
> end;
>
> procedure TRegistry.SetRootKey(Value: HKEY);
> begin
>   fRootKey := Value;
> end;
>
> registry.pp
> ===========
> uses
>   {$IFDEF WIN32}
>   Windows,
>   {$ENDIF}
>   Classes, Controls, SysUtils, vclGlobals, lMessages, LCLLinux;
>
> TestReg.pp
> ==========
> program TestReg;
>
> Uses Registry, LCLLinux;
>
> {$mode objfpc}
>
> Var
>   Reg: TRegistry;
>   SubKey: String;
>
> Begin
> SubKey := 'Software\luis';
> Reg := TRegistry.Create;
> Reg.RootKey := HKEY_LOCAL_MACHINE;
> If Reg.DeleteKey(SubKey) Then Writeln('OK')
>  else
>   Writeln('Error: ', SubKey, ' - not empty or it does not exist.');
> Reg.free;
> End.
>
> ========
>
> The previous example has a very great size and uses GTK.
> How can be reduced the size and not be used GTK?
>
> --
>  |--------------------------|
> | Luis R. Hilario            |
> | http://luisdigital.2y.net  |
>  |--------------------------|
>






More information about the Lazarus mailing list