public static List<string> GetNetworkInfo_List(NetworkProp type) { ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("Select " + type + " From Win32_NetworkAdapter"); ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get(); List<string> result = new List<string>(); foreach (ManagementObject managementObject in managementObjectCollection.Cast<ManagementObject>()) { result.Add(managementObject[type.ToString()].ToString()); } return result; }
public static string GetNetworkInfo(NetworkProp type, string name) { ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("Select " + type + " from Win32_NetworkAdapter Where Name = '" + name + "'"); ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get(); string result = null; foreach (ManagementObject managementObject in managementObjectCollection.Cast<ManagementObject>()) { result = managementObject[type.ToString()].ToString(); } return result; }