CAUTION: Be very careful while using the sample provided. Do not try to format any system stores, that will damage your device permanently.

Download the source code

The Storage API provides facility to program the Storage Manager. Using Storage Manager we can perform various operations on storage card like mount, dismount, enumerate, format, etc…

To enumerate storage cards we can use the APIs FindFirstStore and FindNextStore. This will fill the STOREINFO structure with the information about the storage card found. Each store contains one or more partitions. We can use the API FindFirstPartition and FindNextPartition to enumerate the partitions in that store.

To format a partition first we open the store and the partition, then we can use the API FormatVolume or FormatVolumeEx to format it. Before formatting we should dismount the partition using the API DismountPartition and after formatting we can mount the partition using MountPartition

The sample program displays all the stores found in a Combo Box. Upon selecting a store, all the partitions in that stores will be displayed in a List Control. You can right click each entry and format that partition.

I only tested this on my HTC TyTN II and with the microSD card. I didn’t try to format any system stores. Only the microSD card is formatted. Again be very careful while using the sample, formatting a system partition may damage you device permanently.