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#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in WINAPI
- Make screenshot of DirectX window that is hidden and doesn't have focus
- Is it valid to mutilayered a critical section?
- Implementing callback function for dialog-based application
- Where is the 'EnablePinning' property in the ribbon framework's recent items?
- Confusion about CTRL_SHUTDOWN_EVENT handling in DLLs and WM_QUERYENDSESSION
- Standard control transparency. Possible?
- Disable all power options from the Start menu
- call Win32 API in flex to set Window Display Affinity
- heap error after changing from new allocation to smartpointer
- Win API - Delete all files except some
- Finding the default application for a particular file name extension (Even when served by a metro app)
- How do I declare OutputDebugStringA without windows.h macros?
- WPF giving maximize,minimize,resize control to child window
- Can a dialog intercept drag'n'drop messages passed to its controls?
- WinApi and work with several domains
Related Questions in WMI
- How to determine which Windows drives map to which SAN storage devices using WMI?
- Get all visualsvn permissions for particular (user)SID from python WMI
- Facing error "System.IO.FileNotFoundException:"
- Getting access denied when trying to extract system information using a asp.net web application
- Calling a method of a WMI Class
- Invoking a method thtough C#
- How to collect windows performance counter data (WMI) using Logstash forwarder
- How to check if every users on the system has administrator rights in C#
- WMI query for Counter of type RateOfCountsPerSecond32 shows raw value instead of persecond value
- How to access hidden partitions/volumes
- Why can't local Windows 7 Pro machine read its own WMI values?
- Setting Size of String Buffer When Accessing Windows Registry
- How do I retrieve a list of primary users of computers
- wmi SetSecurityDescriptor
- Where is wmi hpqBIntM provider dll located?
Related Questions in WINDOWS-SCRIPTING
- PsExec fails to open the stdin, stdout and stderr named pipes
- JScript is crashing with a very poor reason given
- Undo the actions performed by a .bat file?
- How can I write "exit" word to txt from bat file?
- Use environment variable set by a batch script in the next batch script run
- How to pipe bash script output to a file on windows
- need to check the version value in text file using vbscript
- Why does this jenkins job never complete?
- Is it possible to assign a logon script to a user in a windows machine which is not a part of domain?
- How to call/ execute .WSF (windows script file) from browser
- Visual Studio Build Agent scripted setup
- When to choose development of a PowerShell Module over PowerShell Script
- Getting Working Processes within IIS App Pools
- Implementing a Windows script
- parse the source safe history output and run the diff command
Related Questions in DEVICE-INSTANCE-ID
- SystemManagement - Find a Device instance Path
- How to get USB Device handle using device instance handle?
- how to parse USB Device Instance ID (DIID)?
- Restart USB port WITHOUT reboot (DevCon)
- How to read device information in Android 10?
- How to find the device instance id of a PCSC reader
- Embed the Google assistant in a Windows computer - device instance ID not generated while running the sample code
- Using <cfgmgr32.h> in MFC - Error CR_ACCESS_DENIED
- How to access GPIO, I²C, SPI, and PWM on Windows 10 using SetupDiGetClassDevs() function and what is the importance of GUID over here?
- How to reliably and quickly get the MAC address of a network card given its device instance ID
- Get parent device
- Getting USB Storage Device Instance ID (unique ID) programmatically
- is the USB Instance ID on Windows unique for a device?
- Get device instance DWORD from device instance path string
- How to prevent installation of USB drives which matches a specific VID or ParentID?
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 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.