输出字符串不正确

0 delphi

procedure TForm1.Button1Click( Sender: TObject );
var
    arrSize: array[ 0..255 ] of Char;
begin
    {same formating like in statusbar of Explorer}
    StrFormatByteSize( 70846, arrSize, Length( arrSize ) * Sizeof( arrSize) );
    Label1.Caption := 'Result: ' + arrSize;
end;
Run Code Online (Sandbox Code Playgroud)

StrFormatByteSize要求arrsize为PWideChar.

如何在Delphi 2009中正确显示结果?

Ken*_*ite 5

这在Delphi 2009中运行良好:

procedure TForm1.Button1Click(Sender: TObject);
var
  Buff: UnicodeString;
  TheSize: Int64;
begin
  SetLength(Buff, 255);;
  TheSize := 1024768;
  StrFormatByteSizeW(TheSize, PWideChar(Buff), Length(Buff));
  Label1.Caption := Buff;
end;
Run Code Online (Sandbox Code Playgroud)