Visual Basic 6.0可以通過調(diào)用API函數(shù)格式化一個磁盤,無論是軟盤還是硬盤。
打開一個新的項目(工程1) ,如果你沒有更改過缺省模式,那么Visual Basic 6.0會自動添加一個form1文件,在form1上添加一個命令控件,將下面的代碼拷入。
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
運行此程序。
注意FormatDisk函數(shù)的第一個變量很重要,他的值是0,1,2時代表格式化的分別是:A、B、C盤。
Distributed Median,Alice has an array A, and Bob has an array B. All elements in A and B are distinct. Alice and Bob are interested in finding the median element of their combined arrays.
基于事件驅(qū)動的串口通訊控件
消息幀數(shù)據(jù)格式:
1 0 A B X X
其中 10 為消息標(biāo)識,
AB表示文本長度,L=A*100+B
XX為配位字符,任意
控制幀數(shù)據(jù)格式
0 1 A B M N
其中 01為控制標(biāo)識,
AB為請求標(biāo)識
MN為附加標(biāo)識
11表示請求對方接收文件,M表示描述字串中文件名子串的長度
N表示描述字串中文件大小子串的長度
10通知對方放棄傳輸
00通知文件傳輸完畢
01請求對方發(fā)送數(shù)據(jù), MN為10請求發(fā)送下一個
MN為00請求重發(fā)
數(shù)據(jù)幀數(shù)據(jù)格式
0 0 A B M N
其中 00 為數(shù)據(jù)標(biāo)識,
AB表示數(shù)據(jù)長度,L=A*100+B
MN為校驗,M*100+N=A+B