Sign in Join

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

Mailing lists / lazarus / 2000-11

The registry is alive

11 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

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

Unknown author
to Luis R. Hilario B.: OK: pp/source/fcl/inc/registry.pp If this unit is implemented, the other unit…
Luis R. Hilario B. wrote 48 lines
wrote: > > On Fri, 10 Nov 2000, Stefan Hille wrote: > > > On Fri, Nov 10, 2000 at 11:38:08AM -0400, Luis R. Hilario B. wrote: > > > > > [..TestReg.pp..] > > > > > > The previous example has a very great size and uses GTK. > > > How can be reduced the size and not be used GTK? > > > > The problem is the usage of some lazarus units. If you change the uses line > > in registry.pp to > > > > uses > > Classes, Sysutils; > > > > and add the following code to it's interface the size should be greatly reduced: > > > > ============= > > const > > //============================================== > > // Registry constants > > //============================================== > > { Provided for compatibility with Windows registry ONLY } > > HKEY_CLASSES_ROOT = $80000000; > > HKEY_CURRENT_USER = $80000001; > > HKEY_LOCAL_MACHINE = $80000002; > > HKEY_USERS = $80000003; > > HKEY_PERFORMANCE_DATA = $80000004; > > HKEY_CURRENT_CONFIG = $80000005; > > HKEY_DYN_DATA = $80000006; > > > > > > type > > HKEY = Integer; > > PHKEY = ^HKEY; > > ============== > > > > These definitions are in lcllinux now, which requires gtk (or any other interface?). > > Maybe we should change this some day... > > The FCL contains a TRegistry class that works on Windows. > It should be extended to work on Linux, and should not depend on GTK at all... > OK: pp/source/fcl/inc/registry.pp If this unit is implemented, the other unit (pp/lazarus/lcl/registry.pp) has sense?

In principle pp/lazarus/lcl/registry.pp
should be abandoned if the fcl/inc/registry.pp one is completed for linux, yes.

Michael.

Reply by email

Luis R. Hilario B.
to Luis R. Hilario B.: The changes and new things: registry.inc ============ function TRegistry.DeleteKey(const…
Jeff Wormsley wrote 23 lines
On 11/10/2000 at 11:38 AM Luis R. Hilario B. wrote: >{$IFDEF WIN32} > Val := RegDeleteKey(fRootKey, KeyP); >{$ELSE} > Val := 1; > // Val := XMLRegDeleteKey(fRootKey, KeyP); ??? >{$ENDIF} > If Val = 0 Then Result := True else Result := False; Does anyone else use this form below? {$IFDEF WIN32} Result := (RegDeleteKey(fRootKey, KeyP) = 0); {$ELSE} Result := False; // Result := (XMLRegDeleteKey(fRootKey, KeyP) = 0); ??? {$ENDIF} I find that eliminating the intermediates is somehow "cleaner". Sorry not to comment on the issue at hand, however...

It worked.
Really which was the "trick"? ((LongInt) = 0) ?
I do not know OOP nor Delphi. Days ago I obtained Delphi 5 (Demo) from the site of Borland, to learn.

Thanks Jeff.

|--------------------------| | Luis R. Hilario | | http://luisdigital.2y.net | |--------------------------|

Reply by email

Luis R. Hilario B.
to Luis R. Hilario B.: The changes and new things: registry.inc ============ function TRegistry.DeleteKey(const…
"Jeffrey A. Wormsley" wrote 13 lines
>> Result := (RegDeleteKey(fRootKey, KeyP) = 0); >It worked. >Really which was the "trick"? ((LongInt) = 0) ? >I do not know OOP nor Delphi. Days ago I obtained Delphi 5 (Demo) from >the site of Borland, to learn. The function result is a boolean, and the expression (RegDeleteKey(fRootKey, KeyP) = 0) evaluates to a boolean (think along the lines of IF X = Y THEN...). The outer parenthesis are not needed, but I use them for clarity when assigning to a boolean this way.

In other words:
If the result of the function is equal to 0 then true otherwise false, but that easy! :-D
is function = 0?

Thanks to teach and excuses to me all (by the idiot questions).

|--------------------------| | Luis R. Hilario | | http://luisdigital.2y.net | |--------------------------|

Reply by email

Stefan Hille
to Luis R. Hilario B.: The changes and new things: registry.inc ============ function TRegistry.DeleteKey(const…
Luis R. Hilario B. wrote
[..TestReg.pp..] The previous example has a very great size and uses GTK. How can be reduced the size and not be used GTK?

The problem is the usage of some lazarus units. If you change the uses line in registry.pp to

  uses
     Classes, Sysutils;

and add the following code to it's interface the size should be greatly reduced:

=============
const
//==============================================
// Registry constants
//==============================================
  { Provided for compatibility with Windows registry ONLY }
    HKEY_CLASSES_ROOT     = $80000000;
    HKEY_CURRENT_USER     = $80000001;
    HKEY_LOCAL_MACHINE    = $80000002;
    HKEY_USERS            = $80000003;
    HKEY_PERFORMANCE_DATA = $80000004;
    HKEY_CURRENT_CONFIG   = $80000005;
    HKEY_DYN_DATA         = $80000006;
type
   HKEY = Integer;
   PHKEY = ^HKEY;
==============

These definitions are in lcllinux now, which requires gtk (or any other interface?). Maybe we should change this some day...

bye,

Stefan

--------------------------------------------------------- Stefan Hille email: 48155 Muenster voice: 0251/664695

Reply by email

Luis R. Hilario B.

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

Reply by email

Jeffrey A. Wormsley
to Luis R. Hilario B.
Show quoted text 6 lines
> Result := (RegDeleteKey(fRootKey, KeyP) = 0); It worked. Really which was the "trick"? ((LongInt) = 0) ? I do not know OOP nor Delphi. Days ago I obtained Delphi 5 (Demo) from the site of Borland, to learn.

The function result is a boolean, and the expression (RegDeleteKey(fRootKey, KeyP) = 0) evaluates to a boolean (think along the lines of IF X = Y THEN...). The outer parenthesis are not needed, but I use them for clarity when assigning to a boolean this way.

Jeff.

Reply by email

Curtis White
to Luis R. Hilario B.: The changes and new things: registry.inc ============ function TRegistry.DeleteKey(const…

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 69 lines
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 | |--------------------------|

Reply by email

Luis R. Hilario B.
to Luis R. Hilario B.: The changes and new things: registry.inc ============ function TRegistry.DeleteKey(const…
Stefan Hille wrote 37 lines
On Fri, Nov 10, 2000 at 11:38:08AM -0400, Luis R. Hilario B. wrote: > [..TestReg.pp..] > > The previous example has a very great size and uses GTK. > How can be reduced the size and not be used GTK? The problem is the usage of some lazarus units. If you change the uses line in registry.pp to uses Classes, Sysutils; and add the following code to it's interface the size should be greatly reduced: ============= const //============================================== // Registry constants //============================================== { Provided for compatibility with Windows registry ONLY } HKEY_CLASSES_ROOT = $80000000; HKEY_CURRENT_USER = $80000001; HKEY_LOCAL_MACHINE = $80000002; HKEY_USERS = $80000003; HKEY_PERFORMANCE_DATA = $80000004; HKEY_CURRENT_CONFIG = $80000005; HKEY_DYN_DATA = $80000006; type HKEY = Integer; PHKEY = ^HKEY; ============== These definitions are in lcllinux now, which requires gtk (or any other interface?). Maybe we should change this some day...

Yes you are right.
I hope that "some day" not be very distant. After all it is not difficult to do it.

|--------------------------| | Luis R. Hilario | | http://luisdigital.2y.net | |--------------------------|

Reply by email

Luis R. Hilario B.
to Unknown author: The FCL contains a TRegistry class that works on Windows. It should be extended to work…
Show quoted text 44 lines
On Fri, 10 Nov 2000, Stefan Hille wrote: > On Fri, Nov 10, 2000 at 11:38:08AM -0400, Luis R. Hilario B. wrote: > > > [..TestReg.pp..] > > > > The previous example has a very great size and uses GTK. > > How can be reduced the size and not be used GTK? > > The problem is the usage of some lazarus units. If you change the uses line > in registry.pp to > > uses > Classes, Sysutils; > > and add the following code to it's interface the size should be greatly reduced: > > ============= > const > //============================================== > // Registry constants > //============================================== > { Provided for compatibility with Windows registry ONLY } > HKEY_CLASSES_ROOT = $80000000; > HKEY_CURRENT_USER = $80000001; > HKEY_LOCAL_MACHINE = $80000002; > HKEY_USERS = $80000003; > HKEY_PERFORMANCE_DATA = $80000004; > HKEY_CURRENT_CONFIG = $80000005; > HKEY_DYN_DATA = $80000006; > > > type > HKEY = Integer; > PHKEY = ^HKEY; > ============== > > These definitions are in lcllinux now, which requires gtk (or any other interface?). > Maybe we should change this some day... The FCL contains a TRegistry class that works on Windows. It should be extended to work on Linux, and should not depend on GTK at all...

OK: pp/source/fcl/inc/registry.pp
If this unit is implemented, the other unit (pp/lazarus/lcl/registry.pp) has sense?

|--------------------------| | Luis R. Hilario | | http://luisdigital.2y.net | |--------------------------|

Reply by email

Jeff Wormsley
to Luis R. Hilario B.: The changes and new things: registry.inc ============ function TRegistry.DeleteKey(const…
AM Luis R. Hilario B. wrote 7 lines
{$IFDEF WIN32} Val := RegDeleteKey(fRootKey, KeyP); {$ELSE} Val := 1; // Val := XMLRegDeleteKey(fRootKey, KeyP); ??? {$ENDIF} If Val = 0 Then Result := True else Result := False;

Does anyone else use this form below?

{$IFDEF WIN32}
  Result := (RegDeleteKey(fRootKey, KeyP) = 0);
{$ELSE}
  Result := False;
  //  Result := (XMLRegDeleteKey(fRootKey, KeyP) = 0); ???
{$ENDIF}

I find that eliminating the intermediates is somehow "cleaner".

Sorry not to comment on the issue at hand, however...

Jeff.

Reply by email

Unknown author
to Stefan Hille: The problem is the usage of some lazarus units. If you change the uses line in…
Stefan Hille wrote 37 lines
On Fri, Nov 10, 2000 at 11:38:08AM -0400, Luis R. Hilario B. wrote: > [..TestReg.pp..] > > The previous example has a very great size and uses GTK. > How can be reduced the size and not be used GTK? The problem is the usage of some lazarus units. If you change the uses line in registry.pp to uses Classes, Sysutils; and add the following code to it's interface the size should be greatly reduced: ============= const //============================================== // Registry constants //============================================== { Provided for compatibility with Windows registry ONLY } HKEY_CLASSES_ROOT = $80000000; HKEY_CURRENT_USER = $80000001; HKEY_LOCAL_MACHINE = $80000002; HKEY_USERS = $80000003; HKEY_PERFORMANCE_DATA = $80000004; HKEY_CURRENT_CONFIG = $80000005; HKEY_DYN_DATA = $80000006; type HKEY = Integer; PHKEY = ^HKEY; ============== These definitions are in lcllinux now, which requires gtk (or any other interface?). Maybe we should change this some day...

The FCL contains a TRegistry class that works on Windows. It should be extended to work on Linux, and should not depend on GTK at all...

Michael.

Reply by email