Visual Basic 6.0可以通過(guò)調(diào)用API函數(shù)格式化一個(gè)磁盤,無(wú)論是軟盤還是硬盤。
打開(kāi)一個(gè)新的項(xiàng)目(工程1) ,如果你沒(méi)有更改過(guò)缺省模式,那么Visual Basic 6.0會(huì)自動(dòng)添加一個(gè)form1文件,在form1上添加一個(gè)命令控件,將下面的代碼拷入。
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
運(yùn)行此程序。
注意FormatDisk函數(shù)的第一個(gè)變量很重要,他的值是0,1,2時(shí)代表格式化的分別是:A、B、C盤。
標(biāo)簽:
Visual
Basic
6.0
API
上傳時(shí)間:
2015-10-05
上傳用戶:kytqcool