To get the serial number, I use this code:
List<HardDrive> hdCollection = new List<HardDrive>();
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject wmi_HD in searcher.Get())
{
HardDrive hd = new HardDrive();
hd.Model = wmi_HD["Model"].ToString();
hd.InterfaceType = wmi_HD["InterfaceType"].ToString();
hd.Caption = wmi_HD["Caption"].ToString();
hd.SerialNo = wmi_HD.GetPropertyValue("SerialNumber").ToString();//get the serailNumber of diskdrive
hdCollection.Add(hd);
}
tbHdd.Text = "*** DETECTED HDD INFORMATION ***\r\n\r\n";
foreach (HardDrive hd in hdCollection)
{
tbHdd.Text += string.Format("Caption: {0}\r\nInterface Type: {1}\r\nModel: {2}\r\nSerial Number: {3}\r\n\r\n", hd.Caption, hd.InterfaceType, hd.Model, hd.SerialNo);
}
If I connect 2 USB devices of the same brand and model, it returns the same serial number. Those are the results got:
Caption: Samsung Flash Drive FIT USB Device
Interface Type: USB
Model: Samsung Flash Drive FIT USB Device
Serial Number: AA00000000000489
Caption: Samsung Flash Drive FIT USB Device
Interface Type: USB
Model: Samsung Flash Drive FIT USB Device
Serial Number: AA00000000000489
Do you know any manner to get a different identifier or to get a string that will be different?. We understand that both serial numbers could not be the same.
Thanks