Ignore:
Timestamp:
Jun 29, 2018, 11:44:07 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Modified: Updated IPTV prices.
  • Added: deb package build script.
File:
1 edited

Legend:

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

    r89 r122  
    99
    1010type
    11   TRegistryRoot = (rrKeyClassesRoot = HKEY($80000000),
    12     rrKeyCurrentUser = HKEY($80000001),
    13     rrKeyLocalMachine = HKEY($80000002),
    14     rrKeyUsers = HKEY($80000003),
    15     rrKeyPerformanceData = HKEY($80000004),
    16     rrKeyCurrentConfig = HKEY($80000005),
    17     rrKeyDynData = HKEY($80000006));
     11  TRegistryRoot = (rrKeyClassesRoot, rrKeyCurrentUser, rrKeyLocalMachine,
     12    rrKeyUsers, rrKeyPerformanceData, rrKeyCurrentConfig, rrKeyDynData);
     13
     14  { TRegistryContext }
    1815
    1916  TRegistryContext = record
    2017    RootKey: HKEY;
    2118    Key: string;
     19    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
     
    2626  TRegistryEx = class(TRegistry)
    2727  private
     28    function GetCurrentContext: TRegistryContext;
     29    procedure SetCurrentContext(AValue: TRegistryContext);
    2830  public
    2931    function ReadBoolWithDefault(const Name: string;
     
    3537    function DeleteKeyRecursive(const Key: string): Boolean;
    3638    function OpenKey(const Key: string; CanCreate: Boolean): Boolean;
     39    property CurrentContext: TRegistryContext read GetCurrentContext write SetCurrentContext;
    3740  end;
    3841
    39 function RegContext(RootKey: HKEY; Key: string): TRegistryContext;
    40 
     42const
     43  RegistryRootHKEY: array[TRegistryRoot] of HKEY = (HKEY_CLASSES_ROOT,
     44    HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA,
     45    HKEY_CURRENT_CONFIG, HKEY_DYN_DATA);
    4146
    4247implementation
    4348
    44 function RegContext(RootKey: HKEY; Key: string): TRegistryContext;
     49
     50{ TRegistryContext }
     51
     52class operator TRegistryContext.Equal(A, B: TRegistryContext): Boolean;
     53begin
     54  Result := (A.Key = B.Key) and (A.RootKey = B.RootKey);
     55end;
     56
     57function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext;
     58begin
     59  Result.RootKey := RegistryRootHKEY[RootKey];
     60  Result.Key := Key;
     61end;
     62
     63function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext;
    4564begin
    4665  Result.RootKey := RootKey;
     
    106125end;
    107126
     127function TRegistryEx.GetCurrentContext: TRegistryContext;
     128begin
     129  Result.Key := CurrentPath;
     130  Result.RootKey := RootKey;
     131end;
     132
     133procedure TRegistryEx.SetCurrentContext(AValue: TRegistryContext);
     134begin
     135  RootKey := AValue.RootKey;
     136  OpenKey(AValue.Key, True);
     137end;
     138
    108139function TRegistryEx.ReadBoolWithDefault(const Name: string;
    109140  DefaultValue: Boolean): Boolean;
Note: See TracChangeset for help on using the changeset viewer.