휴대전화 단말기 인터넷 연결 여부 판단

619 단어 delphirio
uses
 IdTCPClient;


function TForm1.checkinternet: Boolean;
var
  tmpidclient: TIdTCPClient;
begin
  Result := False;

  try
    try
      tmpidclient := TIdTCPClient.Create(nil);
      tmpidclient.ReadTimeout := 2000;
      tmpidclient.ConnectTimeout := 2000;
      tmpidclient.Port := 80;
      tmpidclient.Host := 'www.baidu.com';
      tmpidclient.Connect;
      tmpidclient.Disconnect;
      Result := true;
    except
      on e: Exception do
      begin
        Result := False;
      end;

    end;
  finally
    tmpidclient.DisposeOf;
    tmpidclient := nil;
  end;
end;

좋은 웹페이지 즐겨찾기