uses WinInet;
//函数定义
function GetOnlineStatus : 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;
--------------------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
begin
if not GetOnlineStatus then ShowMessage('计算机没有连接网络!')
else
ShowMessage(' 计算机处于网络状态!');
end;