When an USB Disk plugs into CE/Mobile based device, how do you know the folder name of the mounting point? Usually, it should be "USB Disk" but it is really depends on how OS image builder; they may change the folder name for whatever reason.
FindFirstFlashCard looks simple and promising, the drawback is it only available on Windows Mobile. In fact, these find flash card API set will enumerate all of the mountable file system which includes SD card, CF and etc that we don't expect to get.
So I am going to introduce you another way via Storage Manager.
Here is the steps.
- Using FindFirstStore and FindNextStore (http://msdn.microsoft.com/en-us/library/aa916713.aspx) to enumerate all of the storage devices in your CE/Mobile system.
- The Finds Store APIs return StoreInfo, and we can use dwDeviceType to identify if this is an USB Disk by STORAGE_DEVICE_TYPE_USB flag. We can make It is even better, using (STORAGE_DEVICE_TYPE_REMOVABLE_DRIVE | STORAGE_DEVICE_TYPE_REMOVABLE_MEDIA).
- Once we locate the storage device, then use OpenStore with (StoreInfo.szDeviceName) to open the Store.
- Next step is to use FindFirstPartition and FindNextPartition if needed (in case we have one more partitions but should be a rare case), the PartInfo.szVolumeName is the mount point (folder name). Remember to call FindCloseStore and FindClosePartition to free up the resource after use.
Simple and Promising.