-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCheckInternet.pas
More file actions
62 lines (51 loc) · 1.21 KB
/
Copy pathCheckInternet.pas
File metadata and controls
62 lines (51 loc) · 1.21 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
unit CheckInternet;
interface
uses
System.SysUtils, System.Classes, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient;
type
TCheckInternet = class(TIdTCPClient)
IdTCPClient: TIdTCPClient;
private
function CheckInternet: boolean;
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
phost: string;
pport: integer;
published
{ Published declarations }
property status: boolean read CheckInternet;
end;
TCustomNetworkState = class(TObject)
function GetSSID: String; virtual; abstract;
function IsConnected: boolean; virtual; abstract;
function IsWifiConnected: boolean; virtual; abstract;
function IsMobileConnected: boolean; virtual; abstract;
end;
procedure Register;
implementation
function TCheckInternet.CheckInternet: boolean;
begin
try
self.ReadTimeout := 2000;
self.ConnectTimeout := 2000;
self.port := self.pport;
self.host := self.phost;
self.Connect;
if self.Connected then
result := true
else
result := false;
self.Disconnect;
except
result := false;
end;
end;
procedure Register;
begin
RegisterComponents('internet', [TCheckInternet]);
end;
end.