473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

FormatEx Function?

' VOID FormatEx(
' PWCHAR DriveRoot,
' DWORD MediaFlag,
' PWCHAR FSType,
' PWCHAR Label,
' BOOL QuickFormat,
' DWORD ClusterSize,
' PFMIFSCALLBACK CallBackFunc
' );

Anyone try calling this from VB .NET?

<DllImport("FMIFS.DLL", _
EntryPoint:="FormatEx", _
SetLastError:=True, _
CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Private Shared Sub FormatEx _
(ByVal thePath As String, ByVal theFlag As Int32, ByVal
theType As String, ByVal theLabel As String, ByVal theQuickOrNot As
Byte, ByVal theSize As Integer, ByVal theCallBack As
FormatExCallBackDelegate)

'

End Sub

Does this seem right?

The call to FormatEx jumps and I get a call-back to my delegate
function, but I am getting really weird results. I can't seem to find
any docs on FormatEx beyond what is at sysinternals. But it does not
define all the FormatEx call-back commands?
Nov 20 '05 #1
5 8084
On 2003-10-23, Schorschi <Sc*******@DSLExtreme.COM> wrote:
' VOID FormatEx(
' PWCHAR DriveRoot,
' DWORD MediaFlag,
' PWCHAR FSType,
' PWCHAR Label,
' BOOL QuickFormat,
' DWORD ClusterSize,
' PFMIFSCALLBACK CallBackFunc
' );

Anyone try calling this from VB .NET?

<DllImport("FMIFS.DLL", _
EntryPoint:="FormatEx", _
SetLastError:=True, _
CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Private Shared Sub FormatEx _
(ByVal thePath As String, ByVal theFlag As Int32, ByVal
theType As String, ByVal theLabel As String, ByVal theQuickOrNot As
Byte, ByVal theSize As Integer, ByVal theCallBack As
FormatExCallBackDelegate)

'

End Sub

Does this seem right?

The call to FormatEx jumps and I get a call-back to my delegate
function, but I am getting really weird results. I can't seem to find
any docs on FormatEx beyond what is at sysinternals. But it does not
define all the FormatEx call-back commands?


Your declaring the ByVal theQuickOrNot flag as a Byte - it should be an
Integer. At least last time I checked, a win32 BOOL was a 32-bit value.
In fact, I would probably just declare that as a VB Boolean - if all you
need to pass is a true or false value.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2
Tom,

Yeah, I realized that after I posted. The issue I have now is that
although the call works, it does not seem to function as expected. I
have walked thru the code from sysinternals that illustratives
FormatEx, and it works. But when I convert the code to VB .NET, the
FormatEx returns the 'done' command immediately, and the floppy is not
formated.

'
' FormatEx() Is An Undocumented API Routine...
'
' VOID FormatEx(
' PWCHAR DriveRoot,
' DWORD MediaFlag,
' PWCHAR FSType,
' PWCHAR Label,
' BOOL QuickFormat,
' DWORD ClusterSize,
' PFMIFSCALLBACK CallBackFunc
' );
'
' BOOLEAN FormatCallback(
' CALLBACKCOMMAND Command,
' DWORD SubAction,
' PVOID ActionInfo
' );

'

Public Enum FormatCluster

'

SizeDefault = 0
Size512 = 512
Size1K = 1024
Size2K = 2048
Size4K = 4096
Size8K = 8192
Size16K = 16384
Size32K = 32768
Size64K = 65536
Size128K = 131072
Size256K = 262144

End Enum

Public FormatTypeArray As String() = {"FAT"}

Public Enum FormatType

'

FAT = 0

End Enum

Public Enum FormatMedia

'

FMIFS_HARDDISK = &HC
FMIFS_FLOPPY = &H8

End Enum

Public Enum FormatCommand

'

Progress
DoneWithStructure
UnKnown2
UnKnown3
UnKnown4
UnKnown5
InsufficientRights
WriteProtected
UnKnown8
UnKnown9
UnKnownA
Done
UnKnownC
UnKnownD
OutPut
StructureProgress

End Enum

<DllImport("FMIFS.DLL", _
EntryPoint:="FormatEx", _
SetLastError:=True, _
CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Private Shared Sub FormatEx _
(ByVal thePath As String, ByVal theFlag As Int32, ByVal
theType As String, ByVal theLabel As String, ByVal theQuickOrNot As
Boolean, ByVal theSize As Int32, ByVal theCallBack As
FormatExCallBackDelegate)

'

End Sub

Delegate Function FormatExCallBackDelegate _
(ByVal theCommand As FormatCommand, ByVal theSubAction As
Int32, ByVal theAction As IntPtr) As Boolean

Function FormatExCallBack(ByVal theCommand As FormatCommand, ByVal
theSubAction As Int32, ByVal theAction As IntPtr) As Boolean

'

Select Case (theCommand)

Case FormatCommand.Progress

Case FormatCommand.DoneWithStructure

Case FormatCommand.UnKnown2

Case FormatCommand.UnKnown3

Case FormatCommand.UnKnown4

Case FormatCommand.UnKnown5

Case FormatCommand.InsufficientRights

Case FormatCommand.WriteProtected

Case FormatCommand.UnKnown8

Case FormatCommand.UnKnown9 ' Invalid Drive Root?

Case FormatCommand.UnKnownA

Case FormatCommand.Done

Case FormatCommand.UnKnownC

Case FormatCommand.UnKnownD

Case FormatCommand.OutPut

Case FormatCommand.StructureProgress

Case Else

End Select

#If DEBUG Then

'

Debug.WriteLine(String.Format("Command {0}", theCommand))

#End If

Return (True)

End Function

Function HighLevel(ByVal theType As FormatType, ByVal theCluster
As FormatCluster, Optional ByVal theLabel As String = Nothing,
Optional ByVal theQuickOrNot As Boolean = True) As Boolean

'

Select Case (theLabel)

Case Nothing

'

Case Else

'

theLabel = Left(theLabel, 11)

End Select

FormatEx("A:\", 8, "FAT", "TEST", False, 0, AddressOf
FormatExCallBack)

End Function
Nov 20 '05 #3
In article <21**************************@posting.google.com >, Schorschi wrote:
Tom,

Yeah, I realized that after I posted. The issue I have now is that
although the call works, it does not seem to function as expected. I
have walked thru the code from sysinternals that illustratives
FormatEx, and it works. But when I convert the code to VB .NET, the
FormatEx returns the 'done' command immediately, and the floppy is not
formated.

'
' FormatEx() Is An Undocumented API Routine...
'
' VOID FormatEx(
' PWCHAR DriveRoot,
' DWORD MediaFlag,
' PWCHAR FSType,
' PWCHAR Label,
' BOOL QuickFormat,
' DWORD ClusterSize,
' PFMIFSCALLBACK CallBackFunc
' );
'
' BOOLEAN FormatCallback(
' CALLBACKCOMMAND Command,
' DWORD SubAction,
' PVOID ActionInfo
' );

'

Public Enum FormatCluster

'

SizeDefault = 0
Size512 = 512
Size1K = 1024
Size2K = 2048
Size4K = 4096
Size8K = 8192
Size16K = 16384
Size32K = 32768
Size64K = 65536
Size128K = 131072
Size256K = 262144

End Enum

Public FormatTypeArray As String() = {"FAT"}

Public Enum FormatType

'

FAT = 0

End Enum

Public Enum FormatMedia

'

FMIFS_HARDDISK = &HC
FMIFS_FLOPPY = &H8

End Enum

Public Enum FormatCommand

'

Progress
DoneWithStructure
UnKnown2
UnKnown3
UnKnown4
UnKnown5
InsufficientRights
WriteProtected
UnKnown8
UnKnown9
UnKnownA
Done
UnKnownC
UnKnownD
OutPut
StructureProgress

End Enum

<DllImport("FMIFS.DLL", _
EntryPoint:="FormatEx", _
SetLastError:=True, _
CharSet:=CharSet.Unicode, _
ExactSpelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Private Shared Sub FormatEx _
(ByVal thePath As String, ByVal theFlag As Int32, ByVal
theType As String, ByVal theLabel As String, ByVal theQuickOrNot As
Boolean, ByVal theSize As Int32, ByVal theCallBack As
FormatExCallBackDelegate)

'

End Sub

Delegate Function FormatExCallBackDelegate _
(ByVal theCommand As FormatCommand, ByVal theSubAction As
Int32, ByVal theAction As IntPtr) As Boolean

Function FormatExCallBack(ByVal theCommand As FormatCommand, ByVal
theSubAction As Int32, ByVal theAction As IntPtr) As Boolean

'

Select Case (theCommand)

Case FormatCommand.Progress

Case FormatCommand.DoneWithStructure

Case FormatCommand.UnKnown2

Case FormatCommand.UnKnown3

Case FormatCommand.UnKnown4

Case FormatCommand.UnKnown5

Case FormatCommand.InsufficientRights

Case FormatCommand.WriteProtected

Case FormatCommand.UnKnown8

Case FormatCommand.UnKnown9 ' Invalid Drive Root?

Case FormatCommand.UnKnownA

Case FormatCommand.Done

Case FormatCommand.UnKnownC

Case FormatCommand.UnKnownD

Case FormatCommand.OutPut

Case FormatCommand.StructureProgress

Case Else

End Select

#If DEBUG Then

'

Debug.WriteLine(String.Format("Command {0}", theCommand))

#End If

Return (True)

End Function

Function HighLevel(ByVal theType As FormatType, ByVal theCluster
As FormatCluster, Optional ByVal theLabel As String = Nothing,
Optional ByVal theQuickOrNot As Boolean = True) As Boolean

'

Select Case (theLabel)

Case Nothing

'

Case Else

'

theLabel = Left(theLabel, 11)

End Select

FormatEx("A:\", 8, "FAT", "TEST", False, 0, AddressOf
FormatExCallBack)

End Function


Can you give a link to the code before you converted it? I haven't used
the FormatEx call before - so it would help to see the original code
(I'm assuming C or C++?).

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #4
* Sc*******@DSLExtreme.COM (Schorschi) scripsit:
Yo, Tom, You Disappear?


?!?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
2
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: alex | last post by:
I am so confused with these three concept,who can explained it?thanks so much? e.g. var f= new Function("x", "y", "return x * y"); function f(x,y){ return x*y } var f=function(x,y){
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.