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:

  1. Called SetupDiGetClassDevs() to get a descriptor ( HDEVINFO ) of device class information.
  2. Called SetupDiEnumDeviceInfo() to search for information about each of the devices in the information pool referenced by HDEVINFO . In each iteration of the loop, we get information about the next device, recorded in the buffer type SP_DEVINFO_DATA .
  3. Within each iteration, SetupDiGetDeviceInstanceId() is called to get the device instance ID in the format: USB\Vid_04e8&Pid_503b\0002F9A9828E0F06 .
  4. If the received device instance identifier corresponds to that for the device that generated the DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE , then the SetupDiGetDeviceRegistryProperty() function is SetupDiGetDeviceRegistryProperty() 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 ++?

  • 2
    The file from the flash drive is read just like any other file. What exactly do you fail? - Abyx
  • I just never had a flash drive. How, for example, in the program to determine the letter that identifies the volume of the flash drive? - user3769902
  • one
    This is if the letter is. The user can disable the letter for this device. So the question is not devoid of meaning. - VladD
  • Can you give a link to an example for my situation or close to my situation? - user3769902
  • @ user3769902: Apparently, here is a relevant example: msdn.microsoft.com/en-us/library/windows/desktop/ ... Note that there can be many volumes on one USB device, and not all of them can have a letter. - VladD

0