string ComputerName=Dns.GetHostName(); IPHostEntry myHost=new IPHostEntry(); myHost=Dns.Resolve(ComputerName); Console.WriteLine("The name of this computer is : {0}",ComputerName); Console.WriteLine("The IP of this computer is : "); for(int i=0;i<myHost.AddressList.Length;i++) Console.WriteLine("{0}",myHost.AddressList[i].ToString()); Console.Read();程序中的一段,参考一下就可以了
IPHostEntry myHost=new IPHostEntry();
myHost=Dns.Resolve(ComputerName);
Console.WriteLine("The name of this computer is : {0}",ComputerName);
Console.WriteLine("The IP of this computer is : ");
for(int i=0;i<myHost.AddressList.Length;i++)
Console.WriteLine("{0}",myHost.AddressList[i].ToString());
Console.Read();程序中的一段,参考一下就可以了
如果能够得到dns服务器的名称(域名)就好了