これは単純なものです(私は思います)。
Windowsがファイルの[プロパティ]ボックスに表示する方法であるバイト数(ファイルサイズなど)を表示するシステム組み込み関数、またはDelphiから呼び出すことができる誰かが作成した関数はありますか?
例:これは、Windowsのプロパティボックスにさまざまなサイズを表示する方法です。
539 bytes (539 bytes)
35.1 KB (35,974 bytes)
317 MB (332,531,365 bytes)
2.07 GB (2,224,617,077 bytes)
ディスプレイは、バイト、KB、MB、またはGBの使用についてスマートであり、KB、MB、およびGBの有効数字は3桁のみです。次に、括弧内に正確なバイト数を表示し、数千をコンマで区切ります。よく考えられたとても素敵なディスプレイです。
誰かがそのような機能を知っていますか?
編集:私はこれのための機能がなかったことに非常に驚いています。
有益なアイデアをありがとう。私はこれを思いついた、それはうまくいくようだ:
function BytesToDisplay(A:int64): string;
var
A1, A2, A3: double;
begin
A1 := A / 1024;
A2 := A1 / 1024;
A3 := A2 / 1024;
if A1 < 1 then Result := floattostrf(A, ffNumber, 15, 0) + ' bytes'
else if A1 < 10 then Result := floattostrf(A1, ffNumber, 15, 2) + ' KB'
else if A1 < 100 then Result := floattostrf(A1, ffNumber, 15, 1) + ' KB'
else if A2 < 1 then Result := floattostrf(A1, ffNumber, 15, 0) + ' KB'
else if A2 < 10 then Result := floattostrf(A2, ffNumber, 15, 2) + ' MB'
else if A2 < 100 then Result := floattostrf(A2, ffNumber, 15, 1) + ' MB'
else if A3 < 1 then Result := floattostrf(A2, ffNumber, 15, 0) + ' MB'
else if A3 < 10 then Result := floattostrf(A3, ffNumber, 15, 2) + ' GB'
else if A3 < 100 then Result := floattostrf(A3, ffNumber, 15, 1) + ' GB'
else Result := floattostrf(A3, ffNumber, 15, 0) + ' GB';
Result := Result + ' (' + floattostrf(A, ffNumber, 15, 0) + ' bytes)';
end;
これで十分かもしれませんが、もっと良いものはありますか?