高手帮忙,在vb6.0中如何获得硬盘信息?

我只要知道到硬盘的总空间和剩余空间就可以了
2024-11-27 16:32:35
推荐回答(2个)
回答1:

获得剩余空间还好办
http://topic.csdn.net/t/20030212/12/1420351.html
http://topic.csdn.net/t/20010508/08/114477.html
获得总空间就不知道了!

回答2:

Private Sub Command1_Click()
Dim fs As Object, d, s
Set fs = CreateObject("Scripting.FileSystemObject")
drvPath = "C:\" '自己修改此处
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " (Name: "
s = s & d.VolumeName & ")" & vbCrLf
s = s & "容量:" & FormatNumber(d.TotalSize, 0) & "Bytes" & vbCrLf
s = s & "可用空间:" & FormatNumber(d.freeSpace, 0) & "Bytes" & vbCrLf
s = s & "已用空间:" & FormatNumber(d.TotalSize - d.freeSpace, 0) & "Bytes"
MsgBox s
End Sub