Please if anyone knows how to Get HardDisk Serial number in any windows either by coding or adding Alibrary please help me
using System; using System.Collections; using System.Management; namespace HardDriveSample1 { class HardDrive { private string model = null; private string type = null; private string serialNo = null; public string Model { get {return model;} set {model = value;} } public string Type { get {return type;} set {type = value;} } public string SerialNo { get {return serialNo;} set {serialNo = value;} } } class TestProgram { [STAThread] static void Main(string[] args) { ArrayList hdCollection = new ArrayList(); ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive"); foreach(ManagementObject wmi_HD in searcher.Get()) { HardDrive hd = new HardDrive(); hdCollection.Add(hd); } searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia"); int i = 0; foreach(ManagementObject wmi_HD in searcher.Get()) { HardDrive hd = (HardDrive)hdCollection[i]; // get the hardware serial no. if (wmi_HD["SerialNumber"] == null) hd.SerialNo = "None"; else hd.SerialNo = wmi_HD["SerialNumber"].ToString(); ++i; } foreach(HardDrive hd in hdCollection) { Console.WriteLine("Model\t\t: " + hd.Model); Console.WriteLine("Type\t\t: " + hd.Type); Console.WriteLine("Serial No.\t: " + hd.SerialNo); Console.WriteLine(); } Console.WriteLine("Press [Enter] to exit..."); Console.ReadLine(); } } }