uses Winapi.WinSock;
function GetLocalIpList(IPList: TStrings): Integer;
type
TaPInAddr = array [0 .. 10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
HostName : array [0 .. MAX_PATH] of AnsiChar;
NameLen : Integer;
WSData : TWSAData;
lpHostEnt: PHostEnt;
I : Integer;
pptr : PaPInAddr;
begin
Result := 0;
if WSAStartup(MakeWord(2, 0), WSData) <> 0 then
Exit;
try
NameLen := SizeOf(HostName);
FillChar(HostName, NameLen, 0);
NameLen := GetHostName(HostName, NameLen);
if NameLen = SOCKET_ERROR then
Exit;
lpHostEnt := GetHostByName(HostName);
if lpHostEnt = nil then
Exit;
I := 0;
pptr := PaPInAddr(lpHostEnt^.h_addr_list);
IPList.Clear;
while pptr^[I] <> nil do
begin
IPList.Add(string(AnsiString(inet_ntoa(pptr^[I]^))));
Inc(I);
end;
Result := IPList.count;
finally
WSACleanup;
end;
end;