The floppy disk is a common carrier for data, and our software may provide users to back up data onto the floppy disk. To avoid files with viruses on the floppy disk, the safest way is to remind users to format floppy disk.
Visual Basic can format a disk by calling the API function, whether it is a floppy disk or a hard disk.
Open a new project (Project1) if you have not changed the default mode, then Visual Basic will automatically add a FORM1 file, add a command control to Form1, copy the following code.
Option Explicit Private Declare Function SHFormatDrive Lib "shell32" _ (ByVal Hend AS Long, _ ByVal Drive AS Long, _ ByVal FormatID AS Long, _ ByVal Options AS Long) as Long Private Sub FormatDisk (intDrive as integer, blnQuickFormat as Boolean) dim lngReturn As Long; if (blnQuickFormat) then lngReturn = SHFormatDrive (0, intDrive, 0 &, 1 &) else lngReturn = SHFormatDrive (0, intDrive, 0 &, 0 &) end if end Sub Private Sub Command1_Click () call FormatDisk (0, True) End Sub
Run this program.
It is necessary to remind the reader to note that the first variable of the formatDisk function is very important, his value is 0, 1, 2 Times formatted: A, B, C.
Note: Don't use the hard drive when you use this program to practice, the author does not be responsible for the errors and losses that may happen.
More VB Development Skills:
Http://dev.yesky.com/softchannel/72342371928637440/index.shtml