Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get USB serial number c++

Tags:

c++

windows

usb

I'm looking to retrieve the serial number from a USB memory stick on windows in c++.

I have found plenty of C# examples, and c++ for linux but none for c++ and windows.

Edit

  • C++/CLI is not an option unfortunately.
  • I am looking for the serial number of the device not the file system. OR "Device Instance Path" AKA "InstanceID"
like image 239
Steven Smethurst Avatar asked Dec 28 '22 13:12

Steven Smethurst


1 Answers

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

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

There is a trick to doing it, you have to match up USB devices with disk volumes. You want to avoid WMI if you can because it is unreliable.

like image 88
Rafael Baptista Avatar answered Dec 31 '22 03:12

Rafael Baptista