Formatting SD cards



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.

.



Relevant Pages

  • Best rich text editor for PocketPC
    ... I wonder what the best rich text editor for pocketpc is. ... one with these features... ... rtf format and opens ... This can be a problem because I am using formatting (heading ...
    (microsoft.public.pocketpc)
  • Re: Best rich text editor for PocketPC
    ... > I wonder what the best rich text editor for pocketpc is. ... > one with these features... ... > rtf format and opens ... This can be a problem because I am using formatting (heading ...
    (microsoft.public.pocketpc)
  • Formatting SD cards
    ... I have written code to scan and format my sdcard on a pocketPC. ... On one Pocket I have Windows Mobile 2003 SE and on other I have Windows ... DebugPrint(L"Creating partition type %d...", bPartType); ... Formatting partition... ...
    (microsoft.public.windowsce.app.development)
  • Formatting SD cards
    ... I have written code to scan and format my sdcard on a pocketPC. ... On one Pocket I have Windows Mobile 2003 SE and on other I have Windows ... DebugPrint(L"Creating partition type %d...", bPartType); ... Formatting partition... ...
    (microsoft.public.windowsce.platbuilder)
  • PPC2003 - <PRE> tag automatically fits to screen problem?
    ... I am having a problem with the html tag in PPC2003. ... Microsoft say it is supported in Windows Mobile 2003. ... The formatting of the content is OK, the problem is it gets wrapped to fit screen. ...
    (microsoft.public.pocketpc.developer)