以前的答案里肯定有好多!
uses winsock;
function GetIP(hostName:string):string;
var
WSAData: TWSAData;
HostEnt: PHostEnt;
sIP: string;
begin
WSAStartup(2, WSAData);
HostEnt := gethostbyname(PChar(hostName));
if HostEnt <> nil then
begin
with HostEnt^ do
sIP := Format('%d.%d.%d.%d', [Byte(h_addr^[0]), Byte(h_addr^[1]), Byte(h_addr^[2]), Byte(h_addr^[3])]);
end;
WSACleanup;
result:= sIP;
end;