Click to See Complete Forum and Search --> : format a disk II, the return


visual fzz
November 16th, 1999, 11:16 AM
I posted a question yesterday("format a disk")
Someone gives me a function in order to answer my question:

option Explicit
private Declare Function SHFormatDrive Lib "shell32.dll" (byval hwnd as Long, _
byval drive as Long, _
byval fmtid as Long, _
byval options as Long) as Long
private Sub Command1_Click()
Dim l as Long
l = SHFormatDrive(me.hwnd, 0, &HFFFF, 0)
End Sub


Great!!! : It launches the explorer utility to format disk.
That was exactly what i needed.
But I don't know how the arguments works, the values they can accept etc...

I want to master the volume name and the size of the disk and the quick format....
The arguments like 'options' and 'fmtid' seem to controls these problems but how?
Can someone help me???

thanks
Fzz

Sharathms
November 16th, 1999, 09:02 PM
Hi there.
here is some codefor you

option Explicit
private Declare Function SHFormatDrive Lib "shell32.dll" (byval hwnd as Long, _
byval drive as Long, _
byval fmtid as Long, _
byval options as Long) as Long

Const Quick_Format = 0
Const Full_Format = 1
Const Copy_System = 2

private Declare Function SetVolumeLabel Lib "kernel32" Alias "SetVolumeLabelA" _
(byval lpRootPathName as string, byval lpVolumeName as string) as Long


private Sub Command1_Click()

'this is how you change the volume label....
'first argument is path '"A:\" or "C:\" or "D:\"...
'second argument is new label..

If 0 = SetVolumeLabel("A:\", "NewLabel") then
MsgBox "error Accessing Floopy drive"
Exit Sub
End If

'format... dialog
If 0 = SHFormatDrive(me.hwnd, 0, &HFFFF, Quick_Format) then
MsgBox "error Accessing Floopy drive"
End If
'first argument is caller ID
'Second argument is disk to be formated
'0 for first floppy
'1 for second floppy
'3 for Your "C" drive.. so on
'Third is size. pls let me know when you finish this.
'Fouth is the type of format you want to perform
End Sub



hope this helps you.
if you need more information about Drive #...
you can use GetVolumeInformationA defined in Kernel32

private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (byval lpRootPathName as string, byval lpVolumeNameBuffer as string, byval nVolumeNameSize as Long, lpVolumeSerialNumber as Long, lpMaximumComponentLength as Long, lpFileSystemFlags as Long, byval lpFileSystemNameBuffer as string, byval nFileSystemNameSize as Long) as Long




Sharath MS