1 2 uses 3 Winsock; 4 5 {...} 6 7 function getIPs: Tstrings; 8 type 9 TaPInAddr = array[0..10] of PInAddr; 10 PaPInAddr = ^TaPInAddr; 11 var 12 phe: PHostEnt; 13 pptr: PaPInAddr; 14 Buffer: array[0..63] of Char; 15 I: Integer; 16 GInitData: TWSAData; 17 begin 18 WSAStartup($101, GInitData); 19 Result := TstringList.Create; 20 Result.Clear; 21 GetHostName(Buffer, SizeOf(Buffer)); 22 phe := GetHostByName(buffer); 23 if phe = nil then Exit; 24 pPtr := PaPInAddr(phe^.h_addr_list); 25 I := 0; 26 while pPtr^[I] <> nil do 27 begin 28 Result.Add(inet_ntoa(pptr^[I]^)); 29 Inc(I); 30 end; 31 WSACleanup; 32 end; 33 34 {Example of use:} 35 36 procedure TForm1.Button1Click(Sender: TObject); 37 begin 38 ShowMessage('Your IP Address is: ' + GetIps; 39 end;