这是我将字节数转换为字符串的功能。它无法达到4GB:
function BytesToFriendlyString(Value : Int64) : string;
const
OneKB = 1024;
OneMB = OneKB * 1024;
OneGB = OneMB * 1024;
begin
if Value < OneKB then
Result := FormatFloat('#,##0.00 B',Value)
else if Value < OneMB then
Result := FormatFloat('#,##0.00 KB', Value / OneKB)
else if Value < OneGB then
Result := FormatFloat('#,##0.00 MB', Value / OneMB)
else if Value > OneGB then
Result := FormatFloat('#,##0.00 GB', Value / OneGB)
end; (*BytesToFriendlyString*)
这就是它的使用方式:
K := PerfNrList [I] ;
if (K > MgRasPer.TotPorts) or (K < 0) then K := 0 ;
with ConSpeedList.Items [I] do begin
Subitems [1] := BytesToFriendlyString(MgRasPer.PerfXmitCur [K]) ;
Subitems [2] := BytesToFriendlyString(MgRasPer.PerfRecvCur [K]) ;
如何使其处理超过4GB?