Autor Beitrag
Date Murphy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 20.07.02 13:41 
Hi,

Ich nutze diese Funktion, um die Windows Uptime zu berechnen:

ausblenden 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:
26:
function UpTime: string; 
const 
  ticksperday: Integer    = 1000 * 60 * 60 * 24; 
  ticksperhour: Integer   = 1000 * 60 * 60; 
  ticksperminute: Integer = 1000 * 60; 
  tickspersecond: Integer = 1000; 
var 
  t:          Longword; 
  d, h, m, s: Integer; 
begin 
  t := GetTickCount; 

  d := t div ticksperday; 
  Dec(t, d * ticksperday); 

  h := t div ticksperhour; 
  Dec(t, h * ticksperhour); 

  m := t div ticksperminute; 
  Dec(t, m * ticksperminute); 

  s := t div tickspersecond; 

  Result := 'Uptime: ' + IntToStr(d) + ' Days ' + IntToStr(h) + ' Hours ' + IntToStr(m) + 
    ' Minutes ' + IntToStr(s) + ' Seconds'; 
end;

Ich möchte nun die Tage, Stunden, Minuten und Sekunden in jeweils einem Label darstellen,

hat jemand einen Tipp für mich, wie ich das am bsten realisiere :?: Big THX schon mal.

Gruß Date Murphy :)
Currywurst
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 50

Win XP Pro
D3 Pro, D5 Std, D6 Pers
BeitragVerfasst: Sa 20.07.02 17:27 
Titel: hm
komisch, aber ich bin sicher 99% aller hier im forum könnten die frage doch beantworten, warum macht es keiner? :-)

wenn du ein label auf dein form setzt kannst du doch mit z.b. Label1.Caption:='Hallo' den text ändern

in der funktion die du da hast, sind doch die werte schon schön als strings, also ändere das ganze z.b. in eine procedure, die so aussieht:

ausblenden 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:
26:
27:
28:
procedure UpTime;
const 
  ticksperday: Integer    = 1000 * 60 * 60 * 24; 
  ticksperhour: Integer   = 1000 * 60 * 60; 
  ticksperminute: Integer = 1000 * 60; 
  tickspersecond: Integer = 1000; 
var 
  t:          Longword; 
  d, h, m, s: Integer; 
begin 
  t := GetTickCount; 

  d := t div ticksperday; 
  Dec(t, d * ticksperday); 

  h := t div ticksperhour; 
  Dec(t, h * ticksperhour); 

  m := t div ticksperminute; 
  Dec(t, m * ticksperminute); 

  s := t div tickspersecond; 

  Label1.Caption:=IntToStr(d) + ' Days ';
  Label2.Caption:=IntToStr(h) + ' Hours ';
  Label3.Caption:=IntToStr(m) + ' Minutes ';
  Label4.Caption:=IntToStr(s) + ' Seconds'; 
end;


die vier labels mit den entsprechenden namen müssen natürlich da sein...

und damit es dauernd gezeigt wird könntest du es in das event eines timers machen... usw, aber bisschen selber probieren musste auch schon
Date Murphy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Sa 20.07.02 18:06 
Besten Dank, hat alles geklappt.

Gruß Date Murphy :D