Minnu Merin Alex

Minnu Merin Alex

  • NA
  • 191
  • 25.9k

not getting hard drive serial number

Jul 29 2016 1:54 AM
i have tried using the code 
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..

Answers (2)