且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

delphi检查互联网连接

更新时间:2022-10-17 17:07:26

在使用中添加单位 WinNet。使用功能 InternetGetConnectedState返回互联网状态和类型的值。见下文:

Add in your uses the unit "WinNet". With the function "InternetGetConnectedState" return a value for internet state and type. See below:

function YourFunctionName : boolean;
  var
     origin : cardinal;
  begin
     result := InternetGetConnectedState(@origin,0);

     //connections origins by origin value
     //NO INTERNET CONNECTION              = 0;
     //INTERNET_CONNECTION_MODEM           = 1;
     //INTERNET_CONNECTION_LAN             = 2;
     //INTERNET_CONNECTION_PROXY           = 4;
     //INTERNET_CONNECTION_MODEM_BUSY      = 8;
  end;