您的位置:首页 > 理论基础 > 计算机网络

用API测试是否连接网络!

2011-11-26 08:54 246 查看
uses Wininet;

{$R *.dfm}

function NetWorkIsConnect(Url:string='http://www.microsoft.com/'): Boolean;
var
ConTypes : Integer;
begin
Result := false;
ConTypes := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN + INTERNET_CONNECTION_PROXY;
if InternetGetConnectedState(@ConTypes, 0) then //ConTypes := $01 + $02 + $04;
Result := True
else
if InternetCheckConnection(PWideChar(Url), 1, 0) then
Result := True;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: