2

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

JoakDA
  • 305
  • 1
  • 13
  • 2
    Have you verified that the serial numbers are different? Not all manufacturers use unique serial numbers. – Sam Axe Nov 05 '19 at 18:58
  • [Get serial number of usb storage device in .net core 2.1](https://stackoverflow.com/a/51806262/7444103) ( don't mind the `.net core` part, it's the same in .Net Framework). See whether you can find the informations needed to tell the 2 devices apart. – Jimi Nov 05 '19 at 21:40
  • Off topic, but do anyone know of list of USB flash drives with unique serial number? One of few I found is ATP NanoDura... – nietras Sep 14 '22 at 11:19

0 Answers0