How to programmatically get the Device Instance ID (unique ID) of a USB mass storage device that a user just plugged in?
Getting USB Storage Device Instance ID (unique ID) programmatically
4.2k Views Asked by Navaneeth At
2
There are 2 best solutions below
2
Hans Olsson
On
I think you can do it using WMI. Look at the Win32_LogicalDiskToPartition class to get a list of all disk names and then use those names to query the class Win32_DiskDrive and it's PNPDeviceID property.
Actually, look here for better instructions and a nice class that does it for you.
Related Questions in C#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in WINAPI
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Changing the theme of a #32768 (menu) window class at runtime
- Issue with GetOpenFileName while debugging
- How to populate a ListBox with SendMessage?
- Is there a function to end a child process?
- HDR video publishing
- Frameless Qt + WinAPI maximized window size is bigger than the availableGeometry()
- Mount .iso file with python
- What is Win32 x86-64 CONTEXT::VectorRegister for?
- WinAPI - right mouse drag & drop and IContextMenu
- Win32 per-filesystem cache tuning?
- Client connection timeout during Android & Windows PC communication via sockets
- MessageBoxEx sometimes shows as hollow window, border only, and only on Windows 11
- Win32api send message and Pydirectinput and Powertoy (Keyboard Manager ) Not working when open the application
- Would it be possible to run an application right after csrss.exe loads? (Windows)
Related Questions in WMI
- NullReferenceException when Invoking Method to Enable/Disable Smart Card Reader using C#
- Running wmi queries as a non-admin user on a remote machine using C#
- WMI from centos to remote host
- Getting system info using WMI
- Getting Windows version 23H2 from Win32_OperatingSystem
- How do I access a uint64 in a VARIANT structure?
- c++ WMI: Failure to both enumerate and get instance methods (Windows 10 21H2)
- Why is the WMI win32_Process commandline property is giving null for only some processes of non-admin users?
- Associating WinRT DeviceInformation objects with WMI objects (Win32_PnPEntity)
- How to get "Capabilities" of a PnP device in PowerShell
- Only one ManagementEventWatcher process listens for events at a time
- WMI ThreadsPerHost Quota exceeded
- Get SCCM Deployment's Tab properties using PowerShelll
- How to find type of PCI slots on windows server
- What event does Windows use to detect a drive has been unlocked by bitlocker?
Related Questions in WINDOWS-SCRIPTING
- Batch Script-Powershell MessageBox | How do I set TopMost within PS command line of Batch?
- Windows Post Patch Report not showing available/pending updates
- Exiftool - Batch join tags keywords from JSON to jpg files
- How do I create a powershell script to set default file type (.ica specifically) to open with a .exe located in C:\program files (x86)\
- How to add Double quotes to Array elements in Powershell console?
- Can Windows 11 Sound and Display settings be scripted?
- Powershell script to close specific user share drive session
- PowerShell Script to Replace non-HTML Tags
- search a folder recursively to list the file names which contains the string windows
- Logon scripts are running with admin powershell by default can this be changed?
- Microsoft Excel cannot paste the data. FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
- How to automatically set the Application Pool Identity, User Name & Password
- Printing borderless with PowerShell script
- I need help figuring out where my code is getting hung up at
- Trigger jenkins Job with Azure AD Auth
Related Questions in DEVICE-INSTANCE-ID
- Using <cfgmgr32.h> in MFC - Error CR_ACCESS_DENIED
- How to prevent installation of USB drives which matches a specific VID or ParentID?
- SystemManagement - Find a Device instance Path
- Should I use ANDROID_ID as device identification considering no factory reset?
- How to read device information in Android 10?
- Restart USB port WITHOUT reboot (DevCon)
- Get parent information of a USB device C++
- C#: Error in getting device instance handle
- is the USB Instance ID on Windows unique for a device?
- Embed the Google assistant in a Windows computer - device instance ID not generated while running the sample code
- Change/update Firebase notification token or instance id forcefully via code?
- How to access GPIO, I²C, SPI, and PWM on Windows 10 using SetupDiGetClassDevs() function and what is the importance of GUID over here?
- Get parent device
- how to parse USB Device Instance ID (DIID)?
- How to get USB Device handle using device instance handle?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Catch WM_DEVICECHANGE from any window handle by registering for device change notifications. As such:
The lParam of the WM_DEVICECHANGE can be cast to DBT_DEVTYP_DEVICEINTERFACE. Note - when plug in a device you may get multiple WM_DEVICECHANGE notifications. Just filter on the arrival event and ignore duplicates.