简单,这样就可以了
uses ShellAPI, WinSock;
procedure GetIPList(IPs: TStrings);
type
TaPInAddr = array[0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
WSAData: TWSAData;
HostEnt: PHostEnt;
HostName: array[0..MAXBYTE] of Char;
i: Integer;
paddr: PaPInAddr;
begin
WSAStartup($101, WSAData);
IPs.Clear;
GetHostName(HostName, SizeOf(HostName));
HostEnt := GetHostByName(HostName);
if HostEnt = nil then Exit;
paddr := PaPInAddr(HostEnt^.h_addr_list);
i := 0;
while paddr^ <> nil do
begin
IPs.Add(inet_ntoa(paddr^^));
Inc(i);
end;
WSACleanup;
end;