// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Management; public class MainClass { public static void Main(string[] args) { WqlObjectQuery q = new WqlObjectQuery("SELECT * FROM Win32_DiskDrive"); ManagementObjectSearcher res = new ManagementObjectSearcher(q); foreach (ManagementObject o in res.Get()) { Console.WriteLine("Caption = " + o["Caption"]); Console.WriteLine("DeviceID = " + o["DeviceID"]); Console.WriteLine("Decsription = " + o["Description"]); Console.WriteLine("Manufacturer = " + o["Manufacturer"]); Console.WriteLine("MediaType = " + o["MediaType"]); Console.WriteLine("Model = " + o["Model"]); Console.WriteLine("Name = " + o["Name"]); // only Vista & 2008: //Console.WriteLine("SerialNumber = " + o["SerialNumber"]); } } }