Código
ex: Label1.caption:=Getip('www.delphi.eti.br');
--> Declare a Winsock na clausula uses da unit
Function GetIP(WebHostName:string;):string;
var
WSAData: TWSAData;
HostEnt: PHostEnt;
begin
WSAStartup(2, WSAData);
Gethostname(PChar(WebHostName), 255);
SetLength(WebHostName, StrLen(PChar(WebHostName)));
HostEnt := gethostbyname(PChar(WebHostName));
with HostEnt^ do
begin
Result := Format('%d.%d.%d.%d',
[Byte(h_addr^[0]),Byte(h_addr^[1]),
Byte(h_addr^[2]),Byte(h_addr^[3])]);
end;
WSACleanup;
end;
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009