Changeset 371 for Common/URegistry.pas


Ignore:
Timestamp:
Jun 1, 2012, 10:15:16 AM (12 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/URegistry.pas

    r328 r371  
    66
    77uses
    8   Registry;
     8  Classes, Registry;
    99
    1010type
     11
     12  { TRegistryEx }
     13
    1114  TRegistryEx = class(TRegistry)
    1215  private
     
    1821    function ReadFloatWithDefault(const Name: string;
    1922      DefaultValue: Double): Double;
     23    function DeleteKeyRecursive(const Key: string): Boolean;
    2024  end;
    2125
     
    5458end;
    5559
     60function TRegistryEx.DeleteKeyRecursive(const Key: string): Boolean;
     61var
     62  SubKeys: TStringList;
     63  I: Integer;
     64begin
     65  try
     66    SubKeys := TStringList.Create;
     67    if OpenKey(Key, False) and HasSubKeys then begin
     68      GetKeyNames(SubKeys);
     69      for I := 0 to SubKeys.Count - 1 do
     70        DeleteKeyRecursive(Key + '\' + SubKeys[I]);
     71    end;
     72    Result := DeleteKey(Key);
     73  finally
     74    SubKeys.Free;
     75  end;
     76end;
     77
    5678function TRegistryEx.ReadBoolWithDefault(const Name: string;
    5779  DefaultValue: Boolean): Boolean;
Note: See TracChangeset for help on using the changeset viewer.