Einzelnen Beitrag anzeigen

Benutzerbild von retnyg
retnyg

Registriert seit: 12. Feb 2005
193 Beiträge
 
#6

Re: DNS und kein Ende TARecord

  Alt 3. Feb 2006, 11:39
Delphi-Quellcode:
uses winsock;

var
  WSAData: TWSAData;


function GetInAddr(host: string):TInAddr;
var h : PHostEnt;
begin
   result := TInAddr(inet_addr(pchar(host)));
   if cardinal(result) = INADDR_NONE then begin
      h := GetHostByName(pchar(host));
      if h <> nil then begin
        cardinal(result) := pcardinal(h^.h_addr_list^)^;
      end
      else
        cardinal(result) := 0;
   end;
end;

function GetIpAsString(host :string):string;
begin
  result := string(inet_ntoa(GetInAddr(host)));
end;


....

initialization
  if WSAStartUp($0101,WSAData) <> 0 then showmessage('could not load winsock');

finalization
  WSACleanUp;
  Mit Zitat antworten Zitat