I wrote the MFC dialog application in Visual C ++ in MS VS 2013 Ultimate under Windows 7 Ultimate. My application performs connection / extraction detection, in particular, flash drives. For this purpose, the WM_DEVICECHANGE message is caught in the program, and the RegisterDeviceNotification() function is called in the OnInitDialog() function. In my application, the following steps are performed:
- Called
SetupDiGetClassDevs()to get a descriptor (HDEVINFO) of device class information. - Called
SetupDiEnumDeviceInfo()to search for information about each of the devices in the information pool referenced byHDEVINFO. In each iteration of the loop, we get information about the next device, recorded in the buffer typeSP_DEVINFO_DATA. - Within each iteration,
SetupDiGetDeviceInstanceId()is called to get the device instance ID in the format:USB\Vid_04e8&Pid_503b\0002F9A9828E0F06. - If the received device instance identifier corresponds to that for the device that generated the
DBT_DEVICEARRIVALorDBT_DEVICEREMOVECOMPLETE, then theSetupDiGetDeviceRegistryProperty()function isSetupDiGetDeviceRegistryProperty()to get the readable name of this device or its description.
My problem is that I need to program the file reading from the flash drive, if the program has fixed the flash drive connection (i.e., the DBT_DEVICEARRIVAL event has DBT_DEVICEARRIVAL ). How can I do this reading using Visual C ++?