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

来源:百度知道 编辑:UC知道 时间:2024/05/30 17:46:53
我只要知道到硬盘的总空间和剩余空间就可以了

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

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 Su