Entwickler-Ecke

Sonstiges (Delphi) - Gauge Prozess?


foxy - Di 21.01.03 09:10
Titel: Gauge Prozess?
Guden all ma ne Frage zu dem Ding da :lol:

ich rechne meine FreeSpace auf der Platte aus, wo mein Prog drauf iss mmit diesem code

Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
function GetDiskSize(drive:Char; var free_size, total_size: Int64):Boolean;
var
  RootPath       :Array[0..4] of Char;
  RootPtr        :PChar;
  current_dir    :String;
Begin
 RootPath[0] := Drive;
 RootPath[1] := ':';
 RootPath[2] := '\';
 RootPath[3] := #0;
 RootPtr := RootPath;
 current_dir := GetCurrentDir;
 If SetCurrentDir(drive + ':\') then
   begin
     GetDiskFreeSpaceEx(RootPtr, Free_size, Total_size,nil);
     SetCurrentDir(current_dir);
     Result := True;
   end
   else
   Begin
     Result := False;
     Free_size := -1;
     total_size := -1;
   end;
 end;


mir iss klar, das ich bei free_size keine mb oder gigabitewerte bekomme , aber wenn ich das anzeige mit Gauge1.progress := free_size;
isses immer 100% also wie kann ich das umrechnen, das ich die richtige % Zahl rausbekomme?


smiegel - Di 21.01.03 10:39

Hallo,


Quelltext
1:
2:
if (Total_size>0) then Gauge1.progress:=Trunc(Free_size/Total_size*100.0)
  else Gauge1.progress:=0;


foxy - Di 21.01.03 11:06

jaaaa vielen dank es geht :lol:
nur noch kurze frage was iss der befehl Trunc ??


smiegel - Di 21.01.03 11:08

Hallo,

Zitat:

Trunc konvertiert eine Gleitkommazahl in einen Integer-Wert.

X ist ein Gleitkommaausdruck. Die Funktion gibt einen Int64-Wert mit dem gegen 0 gerundeten Wert von X zurück.


foxy - Di 21.01.03 11:19

ahhh dankeschön