Einzelnen Beitrag anzeigen

Schokohase
(Gast)

n/a Beiträge
 
#12

AW: Shop-Zugangsdaten verschlüsseln

  Alt 4. Sep 2018, 15:37
Nichts was ein Class Helper nicht lösen könnte

Delphi-Quellcode:
uses
  System.Classes, System.IniFiles, System.SysUtils;

type
  TCustomIniFileHelper = class helper for TCustomIniFile
  public
    function ReadBytes( const Section, Name: string ): TBytes;
    procedure WriteBytes( const Section, Name: string; const Value: TBytes );
  end;

implementation

{ TCustomIniFileHelper }

function TCustomIniFileHelper.ReadBytes( const Section, Name: string ): TBytes;
var
  stream: TBytesStream;
begin
  stream := TBytesStream.Create( );
  try
    Self.ReadBinaryStream( Section, Name, stream );
    Result := stream.Bytes;
  finally
    stream.Free( );
  end;
end;

procedure TCustomIniFileHelper.WriteBytes( const Section, Name: string; const Value: TBytes );
var
  stream: TBytesStream;
begin
  stream := TBytesStream.Create( Value );
  try
    Self.WriteBinaryStream( Section, Name, stream );
  finally
    stream.Free( );
  end;
end;
  Mit Zitat antworten Zitat