Belirtilen web barındırma adını çözümlemeye çalışarak bir bilgisayara internete bağlı olup olmadığını kontrol eder.
Delphi 10.1 versiyon
program InternetConrol; {$APPTYPE CONSOLE} {$R *.res} uses Winapi.WinSock; function CheckInternetConnection(AHost: PAnsiChar): Boolean; var PHE: PHostEnt; GInitData: TWSAData; begin WSAStartup($101, GInitData); PHE := GetHostByName(AHost); WSACleanup; Result := (PHE <> nil); end ; begin Write(CheckInternetConnection('www.google.com')); Readln; end.
Freepascal
uses winsock,crt; function CheckInternetConnection(AHost: PAnsiChar): Boolean; var PHE: PHostEnt; GInitData: TWSAData; begin WinSock.WSAStartup($101, GInitData); PHE := WinSock.GetHostByName(AHost); WinSock.WSACleanup; CheckInternetConnection := (PHE <> nil); end; begin clrscr; if CheckInternetConnection('www.google.com') then write('Bagli') else write('Degil'); readln; end.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms740632(v=vs.85).aspx