Formatting SD cards
- From: "tech" <mailto.gsingh@xxxxxxxxx>
- Date: 6 Oct 2006 14:30:06 -0700
hello group...
I have written code to scan and format my sdcard on a pocketPC. I have
pocketpc with two different OS.
On one Pocket I have Windows Mobile 2003 SE and on other I have Windows
Mobile 5.0.
My scan fuction works fine for both OS but Format function fails for
Windows Mobile 5.0.
Please can any suggest me what is wron with this.
here is my code and debug output for WM 5.0....gud thing is this code
works for WM 2003 SE.
VOID CardFormat(VOID)
{
BYTE bPartType = PART_DOS32;
HANDLE hStore = INVALID_HANDLE_VALUE,
hPartition = INVALID_HANDLE_VALUE;
STOREINFO StoreInfo;
FORMAT_PARAMS fp;
HINSTANCE hFatUtil = NULL;
PFN_FORMATVOLUMEEX pfnFormatVolumeEx = NULL;
DWORD dwClusSize = 0;
DWORD dwFlags = FATUTIL_FULL_FORMAT;
DWORD dwFatVersion = 16;
DebugPrint(L"Card is about to be Formatted\r\n");
hFatUtil = LoadLibrary(L"fatutil.dll");
if (!(pfnFormatVolumeEx = (PFN_FORMATVOLUMEEX)
GetProcAddress(hFatUtil, L"FormatVolumeEx")))
{
DebugPrint(L"Error loading fatutil\r\n");
}
DebugPrint(L"Opening store...Now");
if ((hStore = OpenStore(L"DSK1:")) == INVALID_HANDLE_VALUE)
{
DebugPrint(L"OpenStore failed\r\n");
}
memset(&StoreInfo, 0x00, sizeof(StoreInfo));
StoreInfo.cbSize = sizeof(StoreInfo);
if (!GetStoreInfo(hStore, &StoreInfo))
{
DebugPrint(L"GetStoreInfo failed\r\n");
}
DebugPrint(L"Dismounting store...");
if (!DismountStore(hStore))
{
DebugPrint(L"failed\r\n");
}
DebugPrint(L"Things seems OK\r\n");
DebugPrint(L"Formatting store...");
if (!FormatStore(hStore))
{
DebugPrint(L"Format failed\r\n");
}
DebugPrint(L"things seems OK\r\n");
DebugPrint(L"Creating partition type %d...", bPartType);
if (!CreatePartitionEx(hStore,
SDCARDLIB_FP_PARTNAME,
bPartType,
StoreInfo.snBiggestPartCreatable)) // ignored, specify for
good measure
{
DebugPrint(L"CreatePartition failed\r\n");
}
if ((hPartition = OpenPartition(hStore, SDCARDLIB_FP_PARTNAME)) ==
INVALID_HANDLE_VALUE)
{
DebugPrint(L"OpenPartition failed\r\n");
}
DebugPrint(L"OK\r\n");
DebugPrint(L"Formatting partition...");
if (!FormatPartitionEx(hPartition, bPartType, FALSE))
{
DebugPrint(L"FormatPartition failed\r\n");
}
DebugPrint(L"OK\r\n");
DebugPrint(L"Formatting volume...");
memset(&fp, 0x00, sizeof(fp));
fp.cbSize = sizeof(fp);
fp.fo.dwClusSize = dwClusSize;
fp.fo.dwRootEntries = SDCARDLIB_FP_ROOTENTRIES;
fp.fo.dwFatVersion = dwFatVersion;
fp.fo.dwNumFats = 1;
fp.fo.dwFlags = dwFlags;
if (pfnFormatVolumeEx(hPartition, &fp) != ERROR_SUCCESS)
{
DebugPrint(L"FormatVolume failed\r\n");
}
DebugPrint(L"Everything Seems OK\r\n");
DebugPrint(L"Mounting partition...");
if (!MountPartition(hPartition))
{
DebugPrint(L"MountPartition failed\r\n");
}
DebugPrint(L"Format Done\r\n");
}
Debug Output....
Opening store...Now
Dismounting store...
Things seems OK
Formatting store...
things seems OK
Creating partition type 11...
OK
Formatting partition...
OK
Formatting volume...
FormatVolume failed
Any help will be appreciated
Thanks.
.
- Prev by Date: Re: Convert JPEG image to 1 BPP Bitmap format
- Next by Date: Re: simple serial string display help
- Previous by thread: Re: Convert JPEG image to 1 BPP Bitmap format
- Next by thread: Re: Go to Low Power until I receive Data from a COM port
- Index(es):
Relevant Pages
|