Function GetInternetConnect: Boolean;
Var
mHost: PHostEnt;
mWSAData: TWSAData;
Begin
WSAStartup(MAKEWORD(2, 0), mWSAData);
Try
mHost := GetHostByName('www.soho.com');
If mHost = Nil Then
Begin
HTTPClient.Host := 'www.microsoft.com';
HTTPClient.Connect(3000);
If HTTPClient.Connected Then Result := True Else Result := False;
HTTPClient.Disconnect;
End
Else
Result := True;
Except
Result := False;
End;
WSACleanUP;
End;
此方法我用了很久。