Autor Beitrag
rafi@work
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Do 24.07.03 16:38 
Mein Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TPingThread.Execute;
var
  CurrentTimeStamp : String;
begin
  if fileexists(FLogPath) then LogList.LoadFromFile(FLogPath);
  LogList.Add('*******************************************');
  LogList.Add('            Deskphone Gestartet');
  LogList.Add('*******************************************');
  while NOT Terminated do
  begin
    if FPing.Ping <> 0 then
    begin
      CurrentTimeStamp := FormatDateTime('dd.mm.yyyy hh:mm:ss" Host %s wurde nicht erreicht',Now);
      Loglist.Add(Format(CurrentTimeStamp,[FPing.Address]));
      LogList.SaveToFile(FLogPath);
    end;
    Sleep(FInterval*1000);
  end;
end;


*******************************
hier pinge ich einen Rechner. Wenn der Rechner nicht erreicht werden kann, wird die entsprechende Meldung in ein log file geschrieben. Nun schreibt es aber immer die Meldung ins log obwohl der Rechner erreichbar wäre. Was ist an dem Code falsch?
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Do 24.07.03 20:04 
Titel: Re: Pingen und Ins Log schreiben, sollte doch so korrekt sei
rafi@work hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
if FPing.Ping <> 0 then
    begin
      CurrentTimeStamp := FormatDateTime('dd.mm.yyyy hh:mm:ss" Host %s wurde nicht erreicht',Now);...



Deine Bedingung sieht falsch aus. Evtl. in if FPing.Ping = 0 then ... umändern :wink:
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Fr 25.07.03 08:39 
Hi Ex0rzist

Genau das wars! :) Danke vielmal! Gruss und schönen Tag
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Fr 25.07.03 12:08 
Danke gleichfalls. :)