.NET CF: Format Storage Card?

R

Rampf

Ok I found this:

http://msdn2.microsoft.com/en-us/library/aa914221.aspx

So I am trying to convert it to VB.NET:

<DllImport("CoreDll.dll")> Shared Function DeviceIoControl(ByVal hDevice
As Integer, ByVal dwIoControlCode As Integer, _
ByVal lpInBuffer As String, ByVal nInBufferSize As
Integer, _
ByVal lpOutBuffer() As Byte, ByVal nOutBufferSize
As Integer, _
ByRef lpBytesReturned As Integer, ByVal
lpOverlapped As Integer) As Integer
End Function
Declare Function CreateFile Lib "coredll" (ByVal lpFileName As String,
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal
lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer,
ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As
Integer

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hVolume As IntPtr = CreateFile("\Speicherkarted\Vol:", 1, 0, 0,
0, 0, 0)
DeviceIoControl(hVolume, IOCTL_DISK_FORMAT_VOLUME, 0, 0, Nothing, 0,
0, 0)
End Sub


My Question is: What value has the constant IOCTL_DISK_FORMAT_VOLUME ?
 
R

Rampf

Ok Second Try:

<DllImport("CoreDll.dll")> Shared Function DeviceIoControl(ByVal hDevice
As Integer, ByVal dwIoControlCode As Integer, _
ByVal lpInBuffer As String, ByVal nInBufferSize As
Integer, _
ByVal lpOutBuffer() As Byte, ByVal nOutBufferSize
As Integer, _
ByRef lpBytesReturned As Integer, ByVal
lpOverlapped As Integer) As Integer
End Function
Const OPEN_EXISTING As Integer = 3
Const GENERIC_READ As Integer = &H80000000
Const GENERIC_WRITE As Integer = &H40000000
Declare Function CreateFile Lib "coredll" (ByVal lpFileName As String,
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal
lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer,
ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As
Integer

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hVolume As IntPtr = CreateFile("\Speicherkarted\Vol:",
(GENERIC_READ Or GENERIC_WRITE), 0, Nothing, OPEN_EXISTING, 0, Nothing)
DeviceIoControl(hVolume, IOCTL_DISK_FORMAT_VOLUME, 0, 0, Nothing,
Nothing, 0, Nothing)
End Sub


But I still dont have the IOCTL_DISK_FORMAT_VOLUME value?
 
S

Simon Hart [MVP]

This will be defined in diskio.h (part of the Windows CE SDK). I don't have
this SDK installed so can't tell you what the value is.
 
R

Rick C

I had a difficult time finding that file, for some reason, but a google
search turned up this:

#define IOCTL_DISK_FORMAT_VOLUME CTL_CODE(IOCTL_DISK_BASE, 0x0088,
METHOD_BUFFERED, FILE_ANY_ACCESS)
 
P

Paul G. Tobey [eMVP]

Really the only way to find out actual values for those things, unless you
want to recreate the structure that the .h files use (macro CTL_CODE,
various values in various parameters to that, etc.), is to actually write a
little C program and run it to get the value. That's how I got the IOCTL
values that OpenNETCF.Net uses for various operations.

Paul T.
 
G

gupta25

Really the only way to find out actual values for those things, unless you
want to recreate the structure that the .h files use (macro CTL_CODE,
various values in various parameters to that, etc.), is to actually write a
little C program and run it to get the value.  That's how I got the IOCTL
values that OpenNETCF.Net uses for various operations.

Paul T.








- Show quoted text -

This is platform builder file. I had similar problem in formating the
SD card, but above method using IOCTL won't work on newer WM phones.
You should use FormatVolumeEx API to format your SD card. To use this
API, use FATUTIL.DLL. Here is more detail
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=617308&SiteID=1
 
R

Rampf

Thanks

I was risky and looped all values :) Until I found it :)
Dirty but working


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> schrieb im Newsbeitrag news:%[email protected]...
 
R

Ron Weiner

I also have a need for this capability, would you mind sharing?

Thanx

Ron W

Rampf said:
Thanks

I was risky and looped all values :) Until I found it :)
Dirty but working


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> schrieb im Newsbeitrag
Really the only way to find out actual values for those things, unless
you want to recreate the structure that the .h files use (macro CTL_CODE,
various values in various parameters to that, etc.), is to actually write
a little C program and run it to get the value. That's how I got the
IOCTL values that OpenNETCF.Net uses for various operations.

Paul T.
 
R

Rampf

Of course I can share it:

Declare Function DeviceIoControl Lib "coredll" (ByVal hDevice As
Integer, ByVal dwIoControlCode As Integer, _
ByVal lpInBuffer As String, ByVal nInBufferSize As
Integer, _
ByVal lpOutBuffer() As Byte, ByVal nOutBufferSize As
Integer, _
ByRef lpBytesReturned As Integer, ByVal lpOverlapped As
Integer) As Integer
Declare Function CreateFile Lib "coredll" (ByVal lpFileName As String,
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal
lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer,
ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As
Integer
Public Shared Function Format(ByVal StorageCard As String) As Boolean
If IsStorageCard(StorageCard) Then
Try
Return
(DeviceIoControl(CreateFile(IIf(StorageCard.EndsWith("\"), StorageCard &
"Vol:", StorageCard & "\Vol:"), (&H80000000 Or &H40000000), 0, Nothing, 3,
0, Nothing), 459296, 0, 0, Nothing, Nothing, 0, Nothing))
Catch ex As Exception
Return False
End Try
Else
Return False
End If
End Function
Private Shared Function IsStorageCard(ByVal Path) As Boolean
' Check if storage card
Dim fsi As New System.IO.DirectoryInfo(Path)
If fsi.Attributes = IO.FileAttributes.Temporary Or
IO.FileAttributes.Directory Then
Return True
Else
Return False
End If
End Function



Ron Weiner said:
I also have a need for this capability, would you mind sharing?

Thanx

Ron W

Rampf said:
Thanks

I was risky and looped all values :) Until I found it :)
Dirty but working


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> schrieb im Newsbeitrag
Really the only way to find out actual values for those things, unless
you want to recreate the structure that the .h files use (macro
CTL_CODE, various values in various parameters to that, etc.), is to
actually write a little C program and run it to get the value. That's
how I got the IOCTL values that OpenNETCF.Net uses for various
operations.

Paul T.

I had a difficult time finding that file, for some reason, but a google
search turned up this:

#define IOCTL_DISK_FORMAT_VOLUME CTL_CODE(IOCTL_DISK_BASE, 0x0088,
METHOD_BUFFERED, FILE_ANY_ACCESS)

This will be defined in diskio.h (part of the Windows CE SDK). I don't
have
this SDK installed so can't tell you what the value is.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


:

Ok Second Try:

<DllImport("CoreDll.dll")> Shared Function DeviceIoControl(ByVal
hDevice
As Integer, ByVal dwIoControlCode As Integer, _
ByVal lpInBuffer As String, ByVal
nInBufferSize As
Integer, _
ByVal lpOutBuffer() As Byte, ByVal
nOutBufferSize
As Integer, _
ByRef lpBytesReturned As Integer, ByVal
lpOverlapped As Integer) As Integer
End Function
Const OPEN_EXISTING As Integer = 3
Const GENERIC_READ As Integer = &H80000000
Const GENERIC_WRITE As Integer = &H40000000
Declare Function CreateFile Lib "coredll" (ByVal lpFileName As
String,
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal
lpSecurityAttributes As Integer, ByVal dwCreationDisposition As
Integer,
ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As
Integer) As
Integer

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hVolume As IntPtr = CreateFile("\Speicherkarted\Vol:",
(GENERIC_READ Or GENERIC_WRITE), 0, Nothing, OPEN_EXISTING, 0,
Nothing)
DeviceIoControl(hVolume, IOCTL_DISK_FORMAT_VOLUME, 0, 0,
Nothing,
Nothing, 0, Nothing)
End Sub


But I still dont have the IOCTL_DISK_FORMAT_VOLUME value?
 
R

Ron Weiner

Thank you, I really appreciate your generosity.

Ron W
Rampf said:
Of course I can share it:

Declare Function DeviceIoControl Lib "coredll" (ByVal hDevice As
Integer, ByVal dwIoControlCode As Integer, _
ByVal lpInBuffer As String, ByVal nInBufferSize As
Integer, _
ByVal lpOutBuffer() As Byte, ByVal nOutBufferSize As
Integer, _
ByRef lpBytesReturned As Integer, ByVal lpOverlapped
As Integer) As Integer
Declare Function CreateFile Lib "coredll" (ByVal lpFileName As String,
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal
lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer,
ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As
Integer
Public Shared Function Format(ByVal StorageCard As String) As Boolean
If IsStorageCard(StorageCard) Then
Try
Return
(DeviceIoControl(CreateFile(IIf(StorageCard.EndsWith("\"), StorageCard &
"Vol:", StorageCard & "\Vol:"), (&H80000000 Or &H40000000), 0, Nothing, 3,
0, Nothing), 459296, 0, 0, Nothing, Nothing, 0, Nothing))
Catch ex As Exception
Return False
End Try
Else
Return False
End If
End Function
Private Shared Function IsStorageCard(ByVal Path) As Boolean
' Check if storage card
Dim fsi As New System.IO.DirectoryInfo(Path)
If fsi.Attributes = IO.FileAttributes.Temporary Or
IO.FileAttributes.Directory Then
Return True
Else
Return False
End If
End Function



Ron Weiner said:
I also have a need for this capability, would you mind sharing?

Thanx

Ron W

Rampf said:
Thanks

I was risky and looped all values :) Until I found it :)
Dirty but working


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> schrieb im Newsbeitrag
Really the only way to find out actual values for those things, unless
you want to recreate the structure that the .h files use (macro
CTL_CODE, various values in various parameters to that, etc.), is to
actually write a little C program and run it to get the value. That's
how I got the IOCTL values that OpenNETCF.Net uses for various
operations.

Paul T.

I had a difficult time finding that file, for some reason, but a google
search turned up this:

#define IOCTL_DISK_FORMAT_VOLUME CTL_CODE(IOCTL_DISK_BASE, 0x0088,
METHOD_BUFFERED, FILE_ANY_ACCESS)

This will be defined in diskio.h (part of the Windows CE SDK). I
don't have
this SDK installed so can't tell you what the value is.
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


:

Ok Second Try:

<DllImport("CoreDll.dll")> Shared Function DeviceIoControl(ByVal
hDevice
As Integer, ByVal dwIoControlCode As Integer, _
ByVal lpInBuffer As String, ByVal
nInBufferSize As
Integer, _
ByVal lpOutBuffer() As Byte, ByVal
nOutBufferSize
As Integer, _
ByRef lpBytesReturned As Integer, ByVal
lpOverlapped As Integer) As Integer
End Function
Const OPEN_EXISTING As Integer = 3
Const GENERIC_READ As Integer = &H80000000
Const GENERIC_WRITE As Integer = &H40000000
Declare Function CreateFile Lib "coredll" (ByVal lpFileName As
String,
ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer,
ByVal
lpSecurityAttributes As Integer, ByVal dwCreationDisposition As
Integer,
ByVal dwFLagsAndAttributes As Integer, ByVal hTemplateFile As
Integer) As
Integer

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hVolume As IntPtr = CreateFile("\Speicherkarted\Vol:",
(GENERIC_READ Or GENERIC_WRITE), 0, Nothing, OPEN_EXISTING, 0,
Nothing)
DeviceIoControl(hVolume, IOCTL_DISK_FORMAT_VOLUME, 0, 0,
Nothing,
Nothing, 0, Nothing)
End Sub


But I still dont have the IOCTL_DISK_FORMAT_VOLUME value?
 
Y

Youraputz

I'm attempting to do the same thing, however in c#, but it isn't quite
working. Here is the code I'm using:

[DllImport("coredll.dll", EntryPoint = "DeviceIoControl",
SetLastError = true)]
internal static extern int DeviceIoControlCE(
IntPtr hDevice,
int dwIoControlCode,
byte[] lpInBuffer,
int nInBufferSize,
byte[] lpOutBuffer,
int nOutBufferSize,
ref int lpBytesReturned,
IntPtr lpOverlapped);

[DllImport("coredll", SetLastError = true)]
static extern IntPtr CreateFile(String lpFileName, UInt32
dwDesiredAccess, UInt32 dwShareMode, IntPtr lpSecurityAttributes,
UInt32 dwCreationDisposition, UInt32 dwFlagsAndAttributes, IntPtr
hTemplateFile);

int blah = 0;
IntPtr myIoCtrl = CreateFile("Storage Card\Vol:", (0x80000000 |
0x40000000), 0, IntPtr.Zero, 3, 0, IntPtr.Zero);
int result = DeviceIoControlCE(myIoCtrl, 459296, null, 0, null, 0, ref
blah, IntPtr.Zero);

I've checked and 0x80000000 and 0x40000000 are generic_read and
generic_write. I also wasn't sure about the 459296, so I found that
as well, and it seems correct.

// #define CTL_CODE( DeviceType, Function, Method,
Access )
//
// ((DeviceType) << 16) | ((Access) << 14) |
((Function) << 2) | (Method)

DeviceType = 0x00000007
Access = 0
Function = 0x0088
Method = 0

When I call the DeviceIoControlCE function it always returns 0, and my
storage card has not been formatted, any thoughts on how to
troubleshoot this?

Thanks.
 
C

Chris Tacke, eMVP

Checking the LastWin32Error is a reasonable debugging tool - it will tell
you why it's failing.

And does this even compile? This doesn't look right:
"Storage Card\Vol:"

You have an escaped "V", which I think is undefined.

I'd probably overload the P/Invoke too to pass IntPtr.Zero, not null, to the
in and out data parameters. "null" probably marshals as a zero, but I'd
rather be certain.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
Y

Youraputz

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.
 
C

Chris Tacke, eMVP

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 community
http://community.OpenNETCF.com
 
Y

Youraputz

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 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;

}
 
C

Chris Tacke, eMVP

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 community
http://community.OpenNETCF.com

Youraputz said:
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 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;

}
 
Y

Youraputz

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/micr...506e0?lnk=gst&q=formatvolume#59f8a86df27506e0

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


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());
}

}
 
P

Paul G. Tobey [eMVP]

Hmmm. That wouldn't work (to remove that IOCTL). I'd be rather surprised
if it didn't work. The VOL: token *does* have to be all uppercase, at least
in CE5. Give that a try.

Paul T.

Youraputz said:
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/micr...506e0?lnk=gst&q=formatvolume#59f8a86df27506e0

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());
}

}
 
P

Paul G. Tobey [eMVP]

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.

Youraputz said:
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/micr...506e0?lnk=gst&q=formatvolume#59f8a86df27506e0

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());
}

}
 

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