I’m using this code to determine when a usb drive is attached to the computer (I want to look for a certain one, if that one is inserted then the program does something).
The part that I’m stuck on is how to write to that drive. If I use CFile to specify the file location, how do I know what drive letter windows assigned to that usb drive? That’s where my question is. How do I write to that usb drive.
Thanks,
When you receive the
WM_DEVICECHANGEmessage for a USB disk thenlParamwill contain a pointer to theDEV_BROADCAST_VOLUMEstructure. Having verified that itsdbcv_devicetypeisDBT_DEVTYP_VOLUMEyou can then look at itsdbcv_unitmaskmember which shows which drive letter(s) the disk has.