Hi
I was hoping somebody might be able to shed some light on this one for me. The code below compiles fine however, when it runs, it throws an "Object reference not set to an instance of an object" error when trying to run the line highlighted.
Can anyone offer any suggestion as to why this is happening please ?
Many thanks
TSSTechie
May The Force Be With You
![[yoda] [yoda] [yoda]](/data/assets/smilies/yoda.gif)
I was hoping somebody might be able to shed some light on this one for me. The code below compiles fine however, when it runs, it throws an "Object reference not set to an instance of an object" error when trying to run the line highlighted.
Can anyone offer any suggestion as to why this is happening please ?
Many thanks
TSSTechie
Code:
Private Declare Sub FormatExt Lib "fmifs.dll" Alias "FormatEx" (ByRef DriveRoot As String, ByVal MediaFlag As Integer, ByRef Format As String, ByRef Label As String, ByVal QuickFormat As Boolean, ByVal ClusterSize As Integer, ByVal Callback As FormateExDelegateFunction)
Private Sub Format()
Dim strDriveRoot As String, strFormat As String, strLabel As String, boolQuickFormat As Boolean, intClusterSize As Integer
strDriveRoot = "F:\"
strFormat = "FAT"
strLabel = "CC4BUILD"
boolQuickFormat = False
intClusterSize = 0
[aqua]FormatExt(strDriveRoot, 8, strFormat, strLabel, boolQuickFormat, intClusterSize, AddressOf FMIFSCallback)[/aqua]
End Sub
Private Enum CallbackCommand
PROGRESS
DONEWITHSTRUCTURE
UNKNOWN2
UNKNOWN3
UNKNOWN4
UNKNOWN5
INSUFFICIENTRIGHTS
WRITEPROTECTED
UNKNOWN8
UNKNOWN9
UNKNOWNA
DONE
UNKNOWNC
UNKNOWND
Output
STRUCTUREPROGRESS
End Enum
Private Delegate Function FormateExDelegateFunction(ByVal Command As Long, ByVal SubAction As Long, ByVal ActionInfo As Long) As Boolean
Private Function FMIFSCallback(ByVal Command As Long, ByVal SubAction As Long, ByVal ActionInfo As Long) As Boolean
Dim bStatus As Boolean
Select Case Command
Case CallbackCommand.DONE
bStatus = CBool(ActionInfo)
If bStatus Then
MsgBox("Drive Format completed")
Else
MsgBox("Drive Format failed")
End If
Case CallbackCommand.WRITEPROTECTED
MsgBox("Disk is write protected")
End Select
FMIFSCallback = True
End Function
![[lightsaber] [lightsaber] [lightsaber]](/data/assets/smilies/lightsaber.gif)
![[trooper] [trooper] [trooper]](/data/assets/smilies/trooper.gif)
![[yoda] [yoda] [yoda]](/data/assets/smilies/yoda.gif)