Andrew Herrmann
Dec 5th, 1999, 09:25 PM
Does anyone know of a way to format a disk (specifically a floppy) from within VB?
TIA
Serge
Dec 5th, 1999, 10:20 PM
Sure! You can use undocumented SHFormatDrive API.
Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
Public Sub FormatDrive(pstrDriveLetter As String)
Dim intDriveNumber As Integer
'This is for the second parameter
'drive number: A: is 0, B: is 1 and so on...
intDriveNumber = UCase(Asc(pstrDriveLetter)) - 65
Call SHFormatDrive(Me.hwnd, intDriveNumber, 0, 0)
End Sub
Usage: FormatDrive DriveToFormat
Example: Call FormatDrive("a:")
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
[This message has been edited by Serge (edited 12-06-1999).]