function InetIsOffline(Flag: Integer): Boolean; stdcall; external 'URL.DLL';
调用代码:
procedure TFrmInternetDemo.Button1Click(Sender: TObject);
begin
if InetIsOffline(0) then
ShowMessage('This computer is not connected to Internet!')
else
ShowMessage('You are connected to Internet!');
end;
function isOnline(): boolean;
var ConTypes : Integer;
begin
ConTypes := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY;
if (InternetGetConnectedState(@ConTypes, 0) = False)
then Result := False
else Result := True;
end;