Win32_NetworkAdapterConfiguration in WMI C#

Here we are retrieving Network Adapter Configuration details of Computer.

using System.Management;

protected void Page_Load(object sender, EventArgs e)

    {

ManagementObjectSearcher objconfig = new ManagementObjectSearcher( "select * from

                                                                                                                                               Win32_Networkadapterconfiguration");

 

        foreach (ManagementObject obj in objconfig.Get())

        {

            if ((bool)obj["IPEnabled" ] ==  true)

            {

                string[] ip = (string[])obj["IPAddress"];

                if (ip != null)

                {

                    Response.Write("IPAddress  -  " + ip[0] + "</br>");

                }

                string[] gate = (string[])obj["DefaultIPGateway"];

                if (gate != null)

                {

                    Response.Write("DefaultIPGateway  -  " + gate[0] + "</br>");

                }

 

                string[] subnet = (string[])obj["IPSubnet"];

                if (subnet != null)

                {

                    Response.Write("IPSubnet  -  " + subnet[0] + "</br>");

                }

 

                Response.Write("MACAddress  -  " + obj["MACAddress" ] +  "</br>");

                Response.Write("Description  -  " + obj["Description" ] +  "</br>");

                Response.Write("DNSHostName  -  " + obj["DNSHostName" ] +  "</br>");

                Response.Write("DHCPServer  -  " + obj["DHCPServer" ] +  "</br>");

                Response.Write("ServiceName  -  " + obj["ServiceName" ] +  "</br>");

                Response.Write("Description  -  " + obj["Description" ] +  "</br>");

                Response.Write("IPEnabled  -  " + obj["IPEnabled" ] +  "</br>");

                Response.Write("DatabasePath  -  " + obj["DatabasePath" ] +  "</br>");

            }

        }

    }

}

Demo

View output :

demoimage