'使用电脑盘符状况
Sub test()
Dim Str$, Disk, N#, I%, TS#, FS#
Str = "Disk" & vbTab & "TotalSize" & vbTab & "UsedSize" & vbTab & "FreeSpace" & vbTab & "Status" & vbNewLine
With CreateObject("scripting.filesystemobject")
For Each Disk In .drives
If Disk.isready Then
TS = Disk.totalsize
FS = Disk.freespace
N = TS
X N, I
Str = Str & Disk.Path & vbTab & N & Choose(I, "KB", "MB", "GB", "TB") & vbTab
N = TS - FS
X N, I
Str = Str & N & Choose(I, "KB", "MB", "GB", "TB") & vbTab
N = FS
X N, I
Str = Str & N & Choose(I, "KB", "MB", "GB", "TB") & vbTab & IIf(I < 3, "Low Space", "Good") & vbNewLine
Else
Str = Str & Disk.Path & vbNewLine
End If
Next Disk
End With
MsgBox Str
End Sub
'-------------------
Function X(ByRef N As Double, ByRef I As Integer)
I = 0
Do While N > 999.9
N = Round(N / 1024, 1)
I = I + 1
Loop
End Function