Detect removable drive (e.g. USB flash drive) C/C++
问题 How can I detect when a removable disk drive is (dis)connected to the system? How to get the mount path (for Linux) and the drive letter (for windows)? EDIT: Is there a way to detect the currently connected devices? 回答1: For Windows, the API RegisterDeviceNotification will let you know when a USB device is added. The information about the volume is given in the DEV_BROADCAST_VOLUME structure. The dbcv_unitmask gives the drive letter. 回答2: You can get the change notifications (for drive added