Hi all, How can i get the current IP address of a local machine? And when it connect to internet, how can i get both the local LAN ip and internet ip(dynamically assigned)?
Thx
Add the System.Net namespace to your file, then:
Call DNS.GetHostName
- To get the local machine's TCP/IP hostname
Call IPHostEntry.AddressList(machine name)
- To get an array of IPAddress objects for the local machine. Remember that a machine can have more than one card, and possibly several virtual addresses
For each IPAddress object in the array (use a foreach() on it):
if (!ia.IsLoopback()) {
// Is a real IP address
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.