function InternetGetConnectedState(dwFlags:Longint;dwReserved:Longint):longint;stdcall;external 'wininet.dll'; function IsConnected():Boolean;implementation{$R *.dfm}function IsConnected():Boolean; begin If InternetGetConnectedState(0, 0)=1 Then IsConnected:=True Else IsConnected:=False; end;
procedure TForm1.Button1Click(Sender: TObject);begin if InternetCheckConnection('http://www.yahoo.com/', 1, 0) then edit1.text:= 'Connected' else edit1.text:= 'Disconnected';end;
function TMyClass.IsInternetConnected: Boolean; //uses WinInet; const // local system uses a modem to connect to the Internet. INTERNET_CONNECTION_MODEM = 1; // local system uses a local area network to connect to the Internet. INTERNET_CONNECTION_LAN = 2; // local system uses a proxy server to connect to the Internet. INTERNET_CONNECTION_PROXY = 4; // local system's modem is busy with a non-Internet connection. INTERNET_CONNECTION_MODEM_BUSY = 8; var dwConnectionTypes : DWORD; begin dwConnectionTypes := INTERNET_CONNECTION_LAN+INTERNET_CONNECTION_MODEM +INTERNET_CONNECTION_PROXY; //Result := InternetGetConnectedState(@dwConnectionTypes, 1); Result := InternetGetConnectedState(@dwConnectionTypes, 0); end;
function IsConnected():Boolean;implementation{$R *.dfm}function IsConnected():Boolean;
begin
If InternetGetConnectedState(0, 0)=1 Then
IsConnected:=True
Else
IsConnected:=False;
end;
const
// local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM = 1;
// local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_LAN = 2;
// local system uses a proxy server to connect to the Internet.
INTERNET_CONNECTION_PROXY = 4;
// local system's modem is busy with a non-Internet connection.
INTERNET_CONNECTION_MODEM_BUSY = 8;
var
dwConnectionTypes : DWORD;
begin
dwConnectionTypes := INTERNET_CONNECTION_LAN+INTERNET_CONNECTION_MODEM
+INTERNET_CONNECTION_PROXY;
//Result := InternetGetConnectedState(@dwConnectionTypes, 1);
Result := InternetGetConnectedState(@dwConnectionTypes, 0);
end;