|
| IP Detection |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.languages.vb.
| Federico |
How Can I get the Local IP Address in VB.NET on a Windows 2000 Machine??? And on Win9x ?
Thanks a lot
Federico ___________________________________________________ Click here to reveal e-mail address
|
|
|
| |
|
| |
| |
| Jun Su |
Hi Federico,
Based on my knowledge, there is no way to get the IP address of local computer directly. You need get the host name of the local computer first. Then, you can get the IP addresses from the name. For several IP addresses that can bind to a local computer, there is an array returned from the method GetHostByName. The following is an sample. It prints out the host name and the IP addresses.
using System; using System.Net;
namespace ConsoleApplication1 { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { string host; host = Dns.GetHostName(); Console.WriteLine(host); IPHostEntry i = Dns.GetHostByName(host); foreach (IPAddress a in i.AddressList) { Console.WriteLine(a); } } } }
Thanks, Jun Su Click here to reveal e-mail address --- This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. ? 2001 Microsoft Corporation. All rights reserved.
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|