function GetIP:string;
var
WSAData:TWSAData;
HostName:array[0..MAX_COMPUTERNAME_LENGTH] of Char;
HostEntHostEnt;
LastIPInAddr;
IPList:^PInAddr;
begin
result:='';
if 0=WSAStartup(MAKEWORD(1,1), WSAData) then
try
if 0=gethostname(HostName, MAX_COMPUTERNAME_LENGTH+1) then
begin
HostEnt:=gethostbyname(HostName);
if HostEnt<>nil then
begin
IPList:=Pointer(HostEnt^.h_addr_list);
repeat
LastIP:=IPList^;
INC(IPList);
until IPList^=nil;
if LastIP<>nil then
result:=inet_ntoa(LastIP^);
end;
end;
finally
WSACleanup;
end;
end;