void Main() { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_Product"); foreach (ManagementObject queryObj in searcher.Get()) { Console.WriteLine("-----------------------------------"); Console.WriteLine("Win32_Product instance"); Console.WriteLine("-----------------------------------"); Console.WriteLine("Name: {0}", queryObj["Name"]); Console.WriteLine("Version: {0}", queryObj["Version"]); } }
void Main() { ManagementClass mgmt = new ManagementClass("Win32_Product"); ManagementObjectCollection objCol = mgmt.GetInstances(); foreach (ManagementObject obj in objCol) { Console.WriteLine("Product Name: {0}, Version: {1}.", obj.Properties["Name"].Value.ToString(), obj.Properties["Version"].Value.ToString()); } }