1 2 {I got angry after I upgraded my Internet connection to a 3 megabit download3 from a 768K. I keeped getting disconnected at rondom times. This app is useful4 to log the date and time of your disconnection and reconnection to the internet.5 I use it to keep a history of my diconnections and to find out from my ISP if6 they were having line problems during the date and time of my disconnection.7 the app works buy using the Indy component TidPWatch. If my disconnection keeps8 up I will have to change ISP's9 10 Thanks Kyser for your Help :-)}11 12 unit Unit1;
13 14 interface15 16 uses17 {..}18 IdBaseComponent, IdComponent, IdIPWatch;
19 20 type21 TForm1 = class(TForm)
22 ip: TIdIPWatch; //Indy component23 Memo1: TMemo;
24 btnClose: TButton;
25 procedure btnCloseClick(Sender: TObject);
26 procedure FormCreate(Sender: TObject);
27 procedure ipStatusChanged(Sender: TObject);
28 procedure FormClose(Sender: TObject; var Action: TCloseAction);
29 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
30 private31 { Private declarations }32 public33 txt:TextFile;
34 sFile:string;
35 { Public declarations }36 end;
37 38 var39 Form1: TForm1;
40 41 implementation42 43 {$R *.dfm}44 45 procedure TForm1.btnCloseClick(Sender: TObject);
46 begin47 Close;
48 end;
49 50 procedure TForm1.FormCreate(Sender: TObject);
51 begin52 // turn on IPwatch53 ip.Active := true;
54 //get file applocation to write log file55 sFile:=extractfilepath(application.ExeName)+'log.txt';
56 assignfile(txt,sFile);
57 ifnot fileexists(sFile) then58 rewrite(txt)
59 else60 append(txt);
61 writeln(txt,'START APP!!' +formatdatetime('dd-mmm-yy hh:nn:ss am/pm', now));
62 end;
63 64 procedure TForm1.ipStatusChanged(Sender: TObject);
65 // writes the change of status to log file66 var67 sHold:string;
68 begin69 if ip.IsOnline then70 sHold:='ON line:'+ formatdatetime('dd-mmm-yy hh:nn:ss am/pm', now)
71 else72 sHold:='OFF line:'+ formatdatetime('dd-mmm-yy hh:nn:ss am/pm', now);
73 writeln(txt,sHold);
74 memo1.Lines.Add(sHold);
75 end;
76 77 procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
78 begin79 closefile(txt);
80 end;
81 82 procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
83 begin84 writeln(txt,'CLOSED APP!!'+formatdatetime('dd-mmm-yy hh:nn:ss am/pm', now));
85 end;
86 87 end.