(Gast)
n/a Beiträge
|
Rechnernamen anhand der IP herausfinden
20. Jul 2003, 12:11
Hallo,
Delphi-Quellcode:
function IPName(IPAddr: String): String;
var
SockAddrIn: TSockAddrIn;
HostEnt: PHostEnt;
WSAData: TWSAData;
begin
WSAStartup($101, WSAData);
SockAddrIn.Sin_Addr.S_Addr := Inet_Addr(PChar(IPAddr));
HostEnt:= GetHostByAddr(@SockAddrIn.Sin_Addr.S_Addr, 4, AF_INET);
if HostEnt <> nil then
begin
Result := StrPas(Hostent^.h_name)
end
else
begin
Result := '';
end;
end;
Aufrufen so:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IPName('127.0.0.1'));
end;
Grüsse, Daniel
|
|
Zitat
|