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.
source share