Get IP address from Win32_NetworkAdapterConfiguration : Win32_NetworkAdapterConfiguration : Network C# Examples


C# Examples » Network » Win32_NetworkAdapterConfiguration »

 

Get IP address from Win32_NetworkAdapterConfiguration









    
using  System;
using  System.Management;

class  MainClass
{
        public  static  void  Main()
        {
                ManagementObjectSearcher  query  =  new  ManagementObjectSearcher("SELECT  *  FROM  Win32_NetworkAdapterConfiguration  WHERE  IPEnabled  =  'TRUE'")  ;
                ManagementObjectCollection  queryCollection  =  query.Get();
                foreach(  ManagementObject  mo  in  queryCollection  )
                {
                        string[]  addresses  =  (string[])mo["IPAddress"];

                        foreach(string  ipaddress  in  addresses)
                        {
                                Console.WriteLine("IP  Address:  {0}",  ipaddress);
                        }
                }
        }
}
    
   
  
   



Output

IP Address: 192.168.1.101
IP Address: 0.0.0.0


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» Win32_NetworkAdapterConfiguration