LAN Web TCP Delphi

Title: Get host name using IP-address
Use IPAddrToName function. This function get host information by using GetHostByAddr function.
function IPAddrToName(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
Rresult:=StrPas(Hostent^.h_name)
end
else
begin
Result:='';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=IPAddrToName(Edit1.Text);
end;