FloppyFormat




Private Declare Function SHFormatDrive Lib "shell32" _
(ByVal hwnd As Long, _
ByVal Drive As Long, _
ByVal fmtID As Long, _
ByVal options As Long) As Long

Private Const FORMAT_QUICK = &H0 ' this is used below
Private Const FORMAT_FULL = &H1
Private Const FORMAT_SYSTEM = &H2

Private Sub cmdFormatFloppy_Click()
Dim retVal As Long ' the return value of SHFormatDrive
Dim lngDrive As Long ' the drive number

' SHFormatDrive must return 0 for Drive A

' ASCII code for "A" is 65 , so if we subtract 65 from the result

' of the ASC function we get 0


lngDrive = (Asc("A") - 65) ' Modify to use with other drives

retVal = SHFormatDrive(Me.hwnd, lngDrive, HFFFF, FORMAT_QUICK)

End Sub
Parameters info for SHFormatDrive function

**** Hwnd ****
The handle of the form calling the function When the
function is called, the format dialog is linked to the form

**** Drive ****
The drive number to format. Drives are assigned a unique
number : 0 for the drive A , 1 for drive B , 2 for drive C etc.

**** fmtID ****
Set this parameter to the constant #HFFFF

**** Options *****
It is used to configure the type of format Three types of
formatting are available : Quick, Full and Copy system files.
Specify the type using one of the following constants










( floppyformat.html )- by Paolo Puglisi - Modifica del 17/12/2023