DELPHI7适用的BytesOf和StringOf

DELPHI7适用的BytesOf和StringOf

 

function BytesOf(const Val: AnsiString): TBytes;
var
  Len: Integer;
begin
  Len := Length(Val);
  SetLength(Result, Len);
  Move(Val[1], Result[0], Len);
end;

function StringOf(const buf:TBytes): AnsiString;
begin
  SetLength(Result, Length(buf));
  CopyMemory(PAnsiChar(result), @buf[0], Length(buf));
end;

  

posted @ 2020-12-30 12:16  delphi中间件  阅读(852)  评论(0编辑  收藏  举报