public static List<string> GetRegistryInfo_List(RegistryProp type) { ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("Select " + type + " From Win32_Registry"); 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 GetRegistryInfo(RegistryProp type, string name) { ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("Select " + type + " from Win32_Registry Where Name = '" + name + "'"); ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get(); string result = null; foreach (ManagementObject managementObject in managementObjectCollection.Cast<ManagementObject>()) { result = managementObject[type.ToString()].ToString(); } return result; }