Geeks With Blogs
Kate Moss' Open Space

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.

  1. 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.
  2. 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).
  3. Once we locate the storage device, then use OpenStore with (StoreInfo.szDeviceName) to open the Store.
  4. 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.

Posted on Sunday, April 4, 2010 7:28 AM | Back to top


Comments on this post: How to Get the Folder Name of USB Disk?

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Kate Moss' Open Space | Powered by: GeeksWithBlogs.net | Join free