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;
StrFormatByteSize要求arrsize为PWideChar。
如何在Delphi 2009中正确显示结果?
答案 0 :(得分: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;
答案 1 :(得分:2)
用WideChar数组替换Char数组,调用StrFormatByteSizeW。