Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to detect when your PC is disconnected or connected from the Internet Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
04-Aug-05
Category
Internet / Web
Language
Delphi All Versions
Views
466
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   {I got angry after I upgraded my Internet connection to a 3 megabit download
3    from a 768K. I keeped getting disconnected at rondom times. This app is useful
4    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 if
6    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 keeps
8    up I will have to change ISP's
9   
10   Thanks Kyser for your Help :-)}
11  
12  unit Unit1;
13  
14  interface
15  
16  uses
17  {..}  
18   IdBaseComponent, IdComponent, IdIPWatch;
19  
20  type
21    TForm1 = class(TForm)
22      ip: TIdIPWatch;  //Indy component
23      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    private
31      { Private declarations }
32    public
33    txt:TextFile;
34    sFile:string;
35      { Public declarations }
36    end;
37  
38  var
39    Form1: TForm1;
40  
41  implementation
42  
43  {$R *.dfm}
44  
45  procedure TForm1.btnCloseClick(Sender: TObject);
46  begin
47  Close;
48  end;
49  
50  procedure TForm1.FormCreate(Sender: TObject);
51  begin
52  // turn on IPwatch
53  ip.Active := true;
54  //get file applocation to write log file
55  sFile:=extractfilepath(application.ExeName)+'log.txt';
56  assignfile(txt,sFile);
57  if not fileexists(sFile) then
58       rewrite(txt)
59    else
60    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 file
66  var
67  sHold:string;
68  begin
69  if  ip.IsOnline then
70    sHold:='ON line:'+ formatdatetime('dd-mmm-yy hh:nn:ss am/pm', now)
71   else
72    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  begin
79  closefile(txt);
80  end;
81  
82  procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
83  begin
84    writeln(txt,'CLOSED APP!!'+formatdatetime('dd-mmm-yy hh:nn:ss am/pm', now));
85  end;
86  
87  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC