unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
function InternetGetConnectedState(lpdwFlags: LPDWORD;dwReserved: DWORD): BOOL; stdcall; external 'WININET.DLL';
var
Form1: TForm1;
implementation
{$R *.dfm}
uses WinInet;
const
INET_CONN_MODEM = 1;
INET_CONN_LAN = 2;
INET_CONN_PROXY = 4;
INET_CONN_MODEM_BUSY = 8;
function IsConnectedToInternet: Boolean;
var
INetConnectionTypes: Integer;
begin
try
INetConnectionTypes := INET_CONN_MODEM + INET_CONN_LAN + INET_CONN_PROXY;
Result:= InternetGetConnectedState(@INetConnectionTypes, 0);
except
Result := false;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
If IsConnectedToInternet Then
ShowMessage('Connected to Internet!!!')
Else
ShowMessage('NOT connected to Internet!!!');
end;
end.
Open in new window
IsConnected('http://www.microsoft.com')