searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
int i = 0;
foreach (ManagementObject wmi_HD in searcher.Get())
{
// get the hard drive from collection
// using index
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;
}
but this is not working for windows 8 and higher versions..