Delphi, How to get all local IPs?

Christopher Chase picture Christopher Chase · Feb 23, 2009 · Viewed 26.1k times · Source

Any one know a way in delphi get a simple list (eg tstrings) of the local ip address.

I have had a look at the other related question, and cant seem to get my head around converting them to delphi.

Answer

Christopher Chase picture Christopher Chase · Apr 30, 2009

in indy 9, there is a unit IdStack, with the class TIdStack

fStack := TIdStack.CreateStack;
try
  edit.caption := fStack.LocalAddress;  //the first address i believe
  ComboBox1.Items.Assign(fStack.LocalAddresses); //all the address'
finally
  freeandnil(fStack); 
end;

works great :)

from Remy Lebeau's Comment

The same exists in Indy 10, but the code is a little different:

TIdStack.IncUsage; 
try 
  GStack.AddLocalAddressesToList(ComboBox1.Items); 
  Edit.Caption := ComboBox1.Items[0]; 
finally 
  TIdStack.DecUsage; 
end;