19
I posted a solution on SO here. This will populate an array of records full of information for every adapter on the system. This includes the IP Address, but also includes MAC address, subnet mask, transferred/recvd packets, description, etc.
Once you've populated the array of records, just enumerate it for the IP Addresses, if that's all you want.
This emulates "ifconfig -a" on Linux:
C:\>ifconfig
0x00000001
"MS TCP Loopback interface"
Link encap: Local loopback
inet addr:127.0.0.1 Mask: 255.0.0.0
MTU: 1520 Speed:10.00 Mbps
Admin status:UP Oper status:OPERATIONAL
RX packets:179805 dropped:0 errors:0 unkown:0
TX packets:179804 dropped:0 errors:0 txqueuelen:0
0x00000002
"Broadcom NetXtreme 57xx Gigabit Controller - Packet Scheduler Miniport"
Link encap: Ethernet HWaddr: XX-XX-XX-XX-XX-XX
inet addr:10.101.101.102 Mask: 255.255.255.0
MTU: 1500 Speed:100.00 Mbps
Admin status:UP Oper status:OPERATIONAL
RX packets:6287896 dropped:0 errors:0 unkown:0
TX packets:5337100 dropped:0 errors:1 txqueuelen:0
Here is the full source of the "ifconfig -a" project. You will also need to grab my helper unit (uAdapterInfo) and include it with this program.
program ifconfig;
{$APPTYPE CONSOLE}
uses
SysUtils,
Classes,
Winsock,
uAdapterInfo in 'uAdapterInfo.pas';
type
TAdapterInfo = array of record
dwIndex: longint;
dwType: longint;
dwMtu: longint;
dwSpeed: extended;
dwPhysAddrLen: longint;
bPhysAddr: string;
dwAdminStatus: longint;
dwOperStatus: longint;
dwLastChange: longint;
dwInOctets: longint;
dwInUcastPThe Jedi Code Library contains a procedure
procedure GetIpAddresses(Results: TStrings);
in unit JclSysInfo