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[] subnets = (string[])mo["IPSubnet"];
foreach(string subnet in subnets)
{
Console.WriteLine("Subnet Mask: {0}", subnet);
}
}
}
}
|