Autor Beitrag
sunday_2
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 7.0
BeitragVerfasst: Mi 06.11.02 17:29 
Hi,

ich möchte in meinem Programm eine Start und Endzeit ermitteln.
Ich kann mir auch über ein label die Zeit anschauen.
Ich möchte jedoch ermitteln wann mein Programm gestartet wurde und wann es beendet wurde. Leider kann man das durch einfaches Manipulieren der Systemzeit beeinflussen.
Wie kann ich den die Systemzeit für den User sperren, solange mein Programm läuft.

Gruß Sunday
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 06.11.02 18:25 
du könntest die zeit bein starten deines programmes in eine variable einlesen und dann per timer erhöhen. so wie halt eine "künstliche" und interne systemuhr

_________________
In the beginning was the word.
And the word was content-type: text/plain.
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Mi 06.11.02 20:59 
Du kannst mit GetTickCount() die Zeit, die seit dem Systemstart vergangen ist, in Millisekunden abfragen. Diese wird durch das Ändern der Systemzeit nicht beeinflusst.

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
sunday_2 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 7.0
BeitragVerfasst: Do 07.11.02 09:48 
Wie funktioniert das mit GetTickCount()?

Ich habe
ausblenden Quelltext
1:
2:
3:
4:
procedure TStatistik.SpeedButton1Click(Sender: TObject);
begin
        l_time_end.Caption:= TimeToStr(GetTickCount());
end;

Bei Click auf den Button bekomme ich allerdings immer nur 00:00:00
Wieso rechnet er die Zeit nicht mit.

Gruß Sunday

P.S. In der Delphi-Hilfe steht leider nichts zu GetTickCount.
sunday_2 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 7.0
BeitragVerfasst: Do 07.11.02 09:53 
Hi Matze,

du hast geschrieben
Zitat:
ausblenden Quelltext
1:
du könntest die zeit bein starten deines programmes in eine variable einlesen und dann per timer erhöhen. so wie halt eine "künstliche" und interne systemuhr					

Wenn ich in Label.Caption:=TimeToStr(Time) eingebe, läuft die Systemzeit mit. Wie schaffe ich es das ich nur die Startzeit als festen Wert bekomme.
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Do 07.11.02 10:25 
Hi
am einfachsten ist die Variante die OregonGhost beschrieben hat. Beim Programmstart rufst du GetTickCount ab und speicherst den Wert in einer Variablen.
Beim Programmende rufst du wieder GetTickCount ab und ziehst davon den Inhalt deiner Variablen ab. Damit hast du die Programmlaufzeit in Millisekunden.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var
  ticks : cardinal;

procedure TStatistik.FormCreate(Sender: TObject);
begin
  ticks := GetTickCount;
end;

procedure TStatistik.SpeedButton1Click(Sender: TObject); 
var
  runningSince: cardinal;
begin 
  runningSince := (GetTickCount - ticks) div 1000; //Zeit in Sekunden
  l_time_end.Caption := TimeToStr( runningSince / 86400 );

end;

Nicht getestet, sollte aber funktionieren.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
sunday_2 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 101


Delphi 7.0
BeitragVerfasst: Do 07.11.02 10:42 
Hat funktionert!

Vielen Dank :D

Gruß Sunday
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 07.11.02 16:41 
na dann ist ja prima !!!

damit spare ich mir jetzt hier einen code zu posten :wink:

_________________
In the beginning was the word.
And the word was content-type: text/plain.