Ignore:
Timestamp:
Sep 5, 2020, 8:10:03 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Build under Lazarus 2.0.10.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/URegistry.pas

    r192 r306  
    11unit URegistry;
    22
    3 {$MODE Delphi}
     3{$MODE delphi}
    44
    55interface
     
    1717    RootKey: HKEY;
    1818    Key: string;
     19    class function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; static; overload;
     20    class function Create(RootKey: HKEY; Key: string): TRegistryContext; static; overload;
    1921    class operator Equal(A, B: TRegistryContext): Boolean;
    20     function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; overload;
    21     function Create(RootKey: HKEY; Key: string): TRegistryContext; overload;
    2222  end;
    2323
     
    2929    procedure SetCurrentContext(AValue: TRegistryContext);
    3030  public
     31    function ReadChar(const Name: string): Char;
     32    procedure WriteChar(const Name: string; Value: Char);
    3133    function ReadBoolWithDefault(const Name: string;
    3234      DefaultValue: Boolean): Boolean;
    3335    function ReadIntegerWithDefault(const Name: string; DefaultValue: Integer): Integer;
    3436    function ReadStringWithDefault(const Name: string; DefaultValue: string): string;
     37    function ReadCharWithDefault(const Name: string; DefaultValue: Char): Char;
    3538    function ReadFloatWithDefault(const Name: string;
    3639      DefaultValue: Double): Double;
     
    5558end;
    5659
    57 function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext;
     60class function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext;
    5861begin
    5962  Result.RootKey := RegistryRootHKEY[RootKey];
     
    6164end;
    6265
    63 function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext;
     66class function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext;
    6467begin
    6568  Result.RootKey := RootKey;
     
    8588    else begin
    8689      WriteString(Name, DefaultValue);
     90      Result := DefaultValue;
     91    end;
     92end;
     93
     94function TRegistryEx.ReadCharWithDefault(const Name: string; DefaultValue: Char
     95  ): Char;
     96begin
     97  if ValueExists(Name) then Result := ReadChar(Name)
     98    else begin
     99      WriteChar(Name, DefaultValue);
    87100      Result := DefaultValue;
    88101    end;
     
    120133begin
    121134  {$IFDEF Linux}
    122   CloseKey;
     135  //CloseKey;
    123136  {$ENDIF}
    124137  Result := inherited OpenKey(Key, CanCreate);
     
    137150end;
    138151
     152function TRegistryEx.ReadChar(const Name: string): Char;
     153var
     154  S: string;
     155begin
     156  S := ReadString(Name);
     157  if Length(S) > 0 then Result := S[1]
     158    else Result := #0;
     159end;
     160
     161procedure TRegistryEx.WriteChar(const Name: string; Value: Char);
     162begin
     163  WriteString(Name, Value);
     164end;
     165
    139166function TRegistryEx.ReadBoolWithDefault(const Name: string;
    140167  DefaultValue: Boolean): Boolean;
Note: See TracChangeset for help on using the changeset viewer.