Get USB C ++ Serial Number

I am looking to get a serial number from a USB drive on windows in C ++.

I found many examples of C # and C ++ for linux, but not for C ++ and windows.

Edit

  • C ++ / CLI is unfortunately not an option.
  • I am looking for the serial number of the device, not the file system. OR "Device Instance Path" AKA "InstanceID"
+4
source share
3 answers

If C ++ is a requirement, you will have to write COM code. I didn’t like it a bit compared to the VB.NET code, but there are very good examples available in the MSDN library , you just need to adapt the request.

Remember that the example you provided does not return the serial number of the device itself, but only the file system on the device. As good as it gets, USB devices don't have serial numbers.

File system serial numbers are trivial to duplicate if you plan on writing some kind of forced licensing scheme. If this is important, you should use a USB device designed for this purpose. Door. Impossible to crack. And the C ++ code for checking the license will be available from the manufacturer.

+3
source

I have an article on how to get USB serial numbers for volumes in C ++, without using WMI

http://oroboro.com/usb-serial-number/

There is a trick for this, you need to map USB devices to disk volumes. You want to avoid WMI if you can, because it is unreliable.

+6
source

The serial number is a unit under HKLM\SYSTEM\CCS\Enum\USB\Vid_xxxx&Pid_yyyy

+1
source

Source: https://habr.com/ru/post/1313563/


All Articles