.NET CF: Format Storage Card?

Y

Youraputz

Thanks for the reply, I've already switched my code over to use
FormatVolume(). All of this is in C#/CE6.0, but it is getting very
close. I'm now creating a Format_Params struct, filling the
approriate values, and just toying with the flags. Interestingly
enough if I use "Hard Disk\\VOL:" I get error 87 again, but if I just
use "DSK2:" it works fine.

And I should have said that, since you're using FAT, you should be using
FormatVolume(), not telling the disk driver to do a low-level format...

Paul T.


Actually I just found this post, which claims the IOCTL I'm trying to
use has been removed in 6.0.

I'm 99% certain that the "VOL:" text in the name is case sensitive and
*must* be all upper case (thank Paul Tobey for his pain last week in
finding
that during an unrelated issue).
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

On May 29, 11:07 am, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
87 == invalid parameter, so something you're sending it it doesn't
like.
Do
you have a working example in C? That's where I'd start.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

I tried changing the nulls to IntPtr.Zero, and as for the escaped
char, sorry, I missed the @ before the string. Checking GetLatError
is returning 87.
I just wrote a version in C to remove any of the C# issues that may
exist. I still get 87 when I run this code, but here it is, I've
included wince600\public\common\oak\inc and wince600\public\common\sdk
\inc in the project. I also tried changing "storage card" to "hard
disk" and tried with a usb drive, same error 87.
#include <windows.h>
#include <diskio.h>
#include <winioctl.h>
#include <stdio.h>
void main(int argc, char *argv[])
{
HANDLE hDevice;
BOOL bResult;
DWORD junk;
hDevice = CreateFile(TEXT("\\Storage Card\\Vol:"), 0, FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
printf("Invalid Handle\n");
return;
}
bResult = DeviceIoControl(hDevice,IOCTL_DISK_FORMAT_VOLUME, NULL, 0,
NULL, 0, &junk, (LPOVERLAPPED)NULL);
if (bResult == false)
{
printf("Last Error: %d\n", GetLastError());
}
CloseHandle(hDevice);
return;
}
 
G

gupta25

Thanks for the reply, I've already switched my code over to use
FormatVolume(). All of this is in C#/CE6.0, but it is getting very
close. I'm now creating a Format_Params struct, filling the
approriate values, and just toying with the flags. Interestingly
enough if I use "Hard Disk\\VOL:" I get error 87 again, but if I just
use "DSK2:" it works fine.

And I should have said that, since you're using FAT, you should be using
FormatVolume(), not telling the disk driver to do a low-level format...
news:aa64f548-1a79-4cc3-86b4-75f464a3bd31@p39g2000prm.googlegroups.com...
Actually I just found this post, which claims the IOCTL I'm trying to
use has been removed in 6.0.
http://groups.google.com/group/microsoft.public.windowsce.platbuilder...
On Jun 3, 9:30 am, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
I'm 99% certain that the "VOL:" text in the name is case sensitive and
*must* be all upper case (thank Paul Tobey for his pain last week in
finding
that during an unrelated issue).
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

On May 29, 11:07 am, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
87 == invalid parameter, so something you're sending it it doesn't
like.
Do
you have a working example in C? That's where I'd start.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

I tried changing the nulls to IntPtr.Zero, and as for the escaped
char, sorry, I missed the @ before the string. Checking GetLatError
is returning 87.
I just wrote a version in C to remove any of the C# issues that may
exist. I still get 87 when I run this code, but here it is, I've
included wince600\public\common\oak\inc and wince600\public\common\sdk
\inc in the project. I also tried changing "storage card" to "hard
disk" and tried with a usb drive, same error 87.
#include <windows.h>
#include <diskio.h>
#include <winioctl.h>
#include <stdio.h>
void main(int argc, char *argv[])
{
HANDLE hDevice;
BOOL bResult;
DWORD junk;
hDevice = CreateFile(TEXT("\\Storage Card\\Vol:"), 0, FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
printf("Invalid Handle\n");
return;
}
bResult = DeviceIoControl(hDevice,IOCTL_DISK_FORMAT_VOLUME, NULL, 0,
NULL, 0, &junk, (LPOVERLAPPED)NULL);
if (bResult == false)
{
printf("Last Error: %d\n", GetLastError());
}
CloseHandle(hDevice);
return;
}

How would you guarantee that "DSK2:" is SD card? There are device like
Symbol MC70 series which has multiple partitions.
 
Y

Youraputz

Well in general you can't, however in our device there is only 1
attached CF card, and the users have no access to it.

Thanks for the reply, I've already switched my code over to use
FormatVolume(). All of this is in C#/CE6.0, but it is getting very
close. I'm now creating a Format_Params struct, filling the
approriate values, and just toying with the flags. Interestingly
enough if I use "Hard Disk\\VOL:" I get error 87 again, but if I just
use "DSK2:" it works fine.
On Jun 3, 10:57 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
And I should have said that, since you're using FAT, you should be using
FormatVolume(), not telling the disk driver to do a low-level format...
Paul T.

Actually I just found this post, which claims the IOCTL I'm trying to
use has been removed in 6.0.
http://groups.google.com/group/microsoft.public.windowsce.platbuilder...
On Jun 3, 9:30 am, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
I'm 99% certain that the "VOL:" text in the name is case sensitive and
*must* be all upper case (thank Paul Tobey for his pain last week in
finding
that during an unrelated issue).
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

On May 29, 11:07 am, "Chris Tacke, eMVP" <ctacke.at.opennetcf.dot.com>
wrote:
87 == invalid parameter, so something you're sending it it doesn't
like.
Do
you have a working example in C? That's where I'd start.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded communityhttp://community.OpenNETCF.com

I tried changing the nulls to IntPtr.Zero, and as for the escaped
char, sorry, I missed the @ before the string. Checking GetLatError
is returning 87.
I just wrote a version in C to remove any of the C# issues that may
exist. I still get 87 when I run this code, but here it is, I've
included wince600\public\common\oak\inc and wince600\public\common\sdk
\inc in the project. I also tried changing "storage card" to "hard
disk" and tried with a usb drive, same error 87.
#include <windows.h>
#include <diskio.h>
#include <winioctl.h>
#include <stdio.h>
void main(int argc, char *argv[])
{
HANDLE hDevice;
BOOL bResult;
DWORD junk;
hDevice = CreateFile(TEXT("\\Storage Card\\Vol:"), 0, FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE)
{
printf("Invalid Handle\n");
return;
}
bResult = DeviceIoControl(hDevice,IOCTL_DISK_FORMAT_VOLUME, NULL, 0,
NULL, 0, &junk, (LPOVERLAPPED)NULL);
if (bResult == false)
{
printf("Last Error: %d\n", GetLastError());
}
CloseHandle(hDevice);
return;
}

How would you guarantee that "DSK2:" is SD card? There are device like
Symbol MC70 series which has multiple partitions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top