Hottest Free Downloads - DownloadPipe.com Over 197,000 downloads! Bookmark Now!
DownloadPipe.com - New Downloads Every Minute
 SEARCH:
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

.NET CF: Format Storage Card?

 
Goto page 1, 2
   PDA (Home) -> Pocket PC - Developer RSS
Next:  App Configuration File  
Author Message
Rampf

External


Since: Apr 01, 2008
Posts: 13



(Msg. 1) Posted: Tue Apr 01, 2008 10:50 pm
Post subject: .NET CF: Format Storage Card?
Archived from groups: microsoft>public>dotnet>framework>compactframework, others (more info?)

Hello

Is it possible to format a storage card with .NET CF?

THanks a lot!

Rampf
Back to top
Login to vote
Rampf

External


Since: Apr 01, 2008
Posts: 13



(Msg. 2) Posted: Tue Apr 01, 2008 11:14 pm
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 ?



"Rampf" <rampf.RemoveThis@rampf.com> schrieb im Newsbeitrag
news:eXUhSoDlIHA.5396@TK2MSFTNGP04.phx.gbl...
> Hello
>
> Is it possible to format a storage card with .NET CF?
>
> THanks a lot!
>
> Rampf
Back to top
Login to vote
Rampf

External


Since: Apr 01, 2008
Posts: 13



(Msg. 3) Posted: Tue Apr 01, 2008 11:20 pm
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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?
Back to top
Login to vote
Simon Hart [MVP]

External


Since: Jul 14, 2008
Posts: 15



(Msg. 4) Posted: Wed Apr 02, 2008 12:32 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: microsoft>public>pocketpc>developer, others (more info?)

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


"Rampf" wrote:

> 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?
>
>
Back to top
Login to vote
Rick C

External


Since: Apr 02, 2008
Posts: 2



(Msg. 5) Posted: Wed Apr 02, 2008 9:57 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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)

"Simon Hart [MVP]" <srhartone.RemoveThis@yahoo.com> wrote in message
news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
> 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
>
>
> "Rampf" wrote:
>
>> 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?
>>
>>
Back to top
Login to vote
Paul G. Tobey [eMVP]

External


Since: Sep 29, 2006
Posts: 164



(Msg. 6) Posted: Wed Apr 02, 2008 9:57 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

"Rick C" <pixelcat.TakeThisOut@hotmail.example.com> wrote in message
news:uuEdiHNlIHA.6092@TK2MSFTNGP06.phx.gbl...
>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)
>
> "Simon Hart [MVP]" <srhartone.TakeThisOut@yahoo.com> wrote in message
> news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
>> 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
>>
>>
>> "Rampf" wrote:
>>
>>> 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?
>>>
>>>
>
>
Back to top
Login to vote
gupta25

External


Since: Mar 27, 2008
Posts: 4



(Msg. 7) Posted: Wed Apr 02, 2008 10:40 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Apr 2, 8:10 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT no
instrument no spam DOT com> wrote:
> 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.
>
> "Rick C" <pixel....RemoveThis@hotmail.example.com> wrote in message
>
> news:uuEdiHNlIHA.6092@TK2MSFTNGP06.phx.gbl...
>
>
>
> >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)
>
> > "Simon Hart [MVP]" <srhart....RemoveThis@yahoo.com> wrote in message
> >news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
> >> 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
>
> >> "Rampf" wrote:
>
> >>> 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?- Hide quoted text -
>
> - 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
Back to top
Login to vote
Rampf

External


Since: Apr 01, 2008
Posts: 13



(Msg. 8) Posted: Wed Apr 02, 2008 8:27 pm
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks

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


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> schrieb im Newsbeitrag news:%23FwvwONlIHA.1204@TK2MSFTNGP03.phx.gbl...
> 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.
>
> "Rick C" <pixelcat.TakeThisOut@hotmail.example.com> wrote in message
> news:uuEdiHNlIHA.6092@TK2MSFTNGP06.phx.gbl...
>>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)
>>
>> "Simon Hart [MVP]" <srhartone.TakeThisOut@yahoo.com> wrote in message
>> news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
>>> 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
>>>
>>>
>>> "Rampf" wrote:
>>>
>>>> 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?
>>>>
>>>>
>>
>>
>
>
Back to top
Login to vote
Ron Weiner

External


Since: Mar 13, 2008
Posts: 4



(Msg. 9) Posted: Wed Apr 02, 2008 8:27 pm
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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

Thanx

Ron W

"Rampf" <rampf.RemoveThis@rampf.com> wrote in message
news:OtybF9OlIHA.4076@TK2MSFTNGP05.phx.gbl...
> Thanks
>
> I was risky and looped all values Smile Until I found it Smile
> Dirty but working
>
>
> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> com> schrieb im Newsbeitrag
> news:%23FwvwONlIHA.1204@TK2MSFTNGP03.phx.gbl...
>> 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.
>>
>> "Rick C" <pixelcat.RemoveThis@hotmail.example.com> wrote in message
>> news:uuEdiHNlIHA.6092@TK2MSFTNGP06.phx.gbl...
>>>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)
>>>
>>> "Simon Hart [MVP]" <srhartone.RemoveThis@yahoo.com> wrote in message
>>> news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
>>>> 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
>>>>
>>>>
>>>> "Rampf" wrote:
>>>>
>>>>> 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?
>>>>>
>>>>>
>>>
>>>
>>
>>
>
Back to top
Login to vote
Rampf

External


Since: Apr 01, 2008
Posts: 13



(Msg. 10) Posted: Fri Apr 04, 2008 11:29 pm
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <rweineratworksritedotcom> schrieb im Newsbeitrag
news:OCbcE%23RlIHA.6032@TK2MSFTNGP03.phx.gbl...
>I also have a need for this capability, would you mind sharing?
>
> Thanx
>
> Ron W
>
> "Rampf" <rampf DeleteThis @rampf.com> wrote in message
> news:OtybF9OlIHA.4076@TK2MSFTNGP05.phx.gbl...
>> Thanks
>>
>> I was risky and looped all values Smile Until I found it Smile
>> Dirty but working
>>
>>
>> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
>> DOT com> schrieb im Newsbeitrag
>> news:%23FwvwONlIHA.1204@TK2MSFTNGP03.phx.gbl...
>>> 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.
>>>
>>> "Rick C" <pixelcat DeleteThis @hotmail.example.com> wrote in message
>>> news:uuEdiHNlIHA.6092@TK2MSFTNGP06.phx.gbl...
>>>>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)
>>>>
>>>> "Simon Hart [MVP]" <srhartone DeleteThis @yahoo.com> wrote in message
>>>> news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
>>>>> 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
>>>>>
>>>>>
>>>>> "Rampf" wrote:
>>>>>
>>>>>> 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?
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
Back to top
Login to vote
Ron Weiner

External


Since: Mar 13, 2008
Posts: 4



(Msg. 11) Posted: Mon Apr 07, 2008 8:07 pm
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thank you, I really appreciate your generosity.

Ron W
"Rampf" <rampf RemoveThis @rampf.com> wrote in message
news:uJhlsrplIHA.944@TK2MSFTNGP05.phx.gbl...
> 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" <rweineratworksritedotcom> schrieb im Newsbeitrag
> news:OCbcE%23RlIHA.6032@TK2MSFTNGP03.phx.gbl...
>>I also have a need for this capability, would you mind sharing?
>>
>> Thanx
>>
>> Ron W
>>
>> "Rampf" <rampf RemoveThis @rampf.com> wrote in message
>> news:OtybF9OlIHA.4076@TK2MSFTNGP05.phx.gbl...
>>> Thanks
>>>
>>> I was risky and looped all values Smile Until I found it Smile
>>> Dirty but working
>>>
>>>
>>> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
>>> DOT com> schrieb im Newsbeitrag
>>> news:%23FwvwONlIHA.1204@TK2MSFTNGP03.phx.gbl...
>>>> 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.
>>>>
>>>> "Rick C" <pixelcat RemoveThis @hotmail.example.com> wrote in message
>>>> news:uuEdiHNlIHA.6092@TK2MSFTNGP06.phx.gbl...
>>>>>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)
>>>>>
>>>>> "Simon Hart [MVP]" <srhartone RemoveThis @yahoo.com> wrote in message
>>>>> news:24A25950-9103-4741-9142-E0F9BE42171B@microsoft.com...
>>>>>> 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
>>>>>>
>>>>>>
>>>>>> "Rampf" wrote:
>>>>>>
>>>>>>> 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?
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
Back to top
Login to vote
Youraputz

External


Since: May 28, 2008
Posts: 6



(Msg. 12) Posted: Wed May 28, 2008 9:24 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
Back to top
Login to vote
Chris Tacke, eMVP

External


Since: Mar 19, 2008
Posts: 49



(Msg. 13) Posted: Wed May 28, 2008 11:59 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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


"Youraputz" <Youraputz.DeleteThis@gmail.com> wrote in message
news:41e075f9-e2c7-4df6-992d-ea00fa2787d5@w1g2000prd.googlegroups.com...
> 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.
Back to top
Login to vote
Youraputz

External


Since: May 28, 2008
Posts: 6



(Msg. 14) Posted: Thu May 29, 2008 7:26 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
Back to top
Login to vote
Chris Tacke, eMVP

External


Since: Mar 19, 2008
Posts: 49



(Msg. 15) Posted: Thu May 29, 2008 10:07 am
Post subject: Re: .NET CF: Format Storage Card? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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


"Youraputz" <Youraputz DeleteThis @gmail.com> wrote in message
news:86bc5575-25c8-4501-af2b-053d05056e49@u12g2000prd.googlegroups.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.
>
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Hard reset/ storage format WM5 - I try to use below coding to hard reset WM5 but it doesn't work. This coding functions as soft reset in WM5. Kindly pls help. [DllImport("Coredll.dll")] private static extern int KernelIoControl(int dwIoControlCode, IntPtr lpInBuf...

Name of storage card - I still want to get the name of the storage card with visual basic commands for the pocket pc Is this not possible to do with DirectoryInfo or so? Anyone simple code suggestions? Thanks, Hans

GetFullPath of storage card - How can I get the name of the Storage Card on the pocket PC? When I create a specific directory on the storage card and do GetFullpath("specific directory") I only get "\specific directory" as the path and not someting like "St...

how to run EXE from storage card - Hello All, I need some help here.I want to run an EXE with all paramenters from a storage card on windows Mobile device.I have EXE named HOPPER.EXE on storage card,but problem is,if i double click the exe it takes default parameters and..

Get Storage Card Free Space? - Hello How can I get the Free Space of a Storage Card in .NET? I tried to call GetDiskFreeSpaceEx with "\Storage Card" as path, but sometimes it is returning a negative value?! Thanks Rampf
       PDA (Home) -> Pocket PC - Developer All times are: Pacific Time (US & Canada) (change)
Goto page 1, 2
Page 1 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
 Linux Forums
 Mac Forums
  PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact