下面的函数可以列举你机器的所有IP地址
//返回本机IP地址,多个地址之间用回车换行分隔
function GetAllIP : string;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^ <> nil do begin
if i=0
then result:=StrPas(inet_ntoa(pptr^^))
else result:=result+','+StrPas(inet_ntoa(pptr^^));
Inc(I);
end;
WSACleanup;
end;