Can PNPDeviceID meet your requirements?
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
}
Update:
If it is a CD, PNPDeviceID may be possible, but if the device is a usb device, then PNPDeviceID is not feasible, see this link for details:
is pnpdeviceid of video card adapter unique
Assigning a globally unique identifier to each device. I think this may require manufacturers to do this, but they don’t seem to have done so at present, and it seems unlikely that we can do this with code.
In addition, if you want to get the SerialNumber, please look at this class: Win32_CDROMDrive class
Just modify the above query statement and property name.
But I don't have a CD so I haven't tested it yet.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.