Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   REG_DWORD Dezimalzahl in "Datei größe" Formatieren (https://www.delphipraxis.net/109181-reg_dword-dezimalzahl-datei-groesse-formatieren.html)

Metal_Snake2 25. Feb 2008 19:50


REG_DWORD Dezimalzahl in "Datei größe" Formatieren
 
hi,

ich habe z.B. einen schlüssel x mit dem DateiTyp "Reg_DWord".
X soll nun z.B. den Dezimalwert 6676940 haben.

Wie komme ich auf die rechnung das dieser wert 2424,45 MB ist?

Ich meine mit funktionen wie :

Delphi-Quellcode:
function TUtils.FormatFileSize(aSize: INT64): string;
const
  MB = Int64(1024 * 1024);
  GB = Int64(1024 * MB);
  TB = Int64(1024 * GB);
  PB = Int64(1024 * TB);
  cSize : array [0..5] of Int64 = (1, 1024, MB, GB, TB, PB);
  cLabel : array [0..5] of string = ('B', 'KB', 'MB', 'GB', 'TB', 'PB');
var
  lIndex : Integer;
begin
  lIndex := Ord(aSize >= cSize[1]) + Ord(aSize >= cSize[2]) + Ord(aSize >= cSize[3]) + Ord(aSize >= cSize[4]) + Ord(aSize >= cSize[5]);
  Result := Format('%g %s', [Int(100.0 * aSize / cSize[lIndex]) / 100, cLabel[lIndex]]);
end;
komme ich nicht weiter, kann mir einer helfen???
Meine vermuting ist das ich die Dezimalzahl irgendwie mit "Format" zurecht formatieren soll...jedoch habe ich bis jetzt nicht
richtig die Formatierung verstanden.


Danke fürs lesen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:59 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz