做关于表单时,经常会显示系统所在磁盘空间大小等信息
如何获取磁盘类型及空间使用情况?
Imports scripting
Dim fso As New FileSystemObject
Dim drv1 As Drive
Dim str1 As String
drv1 = fso.GetDrive("c:\")
str1 = "驱动器:" & "C:\" & vbCrLf
str1 += "文件系统:" & drv1.FileSystem & vbCrLf
str1 += "磁盘类型:" & drv1.DriveType & vbCrLf
str1 += "磁盘容量:" & FormatNumber(drv1.TotalSize / 1024, 0) & "KB" & vbCrLf
str1 += "可用空间:" & FormatNumber(drv1.FreeSpace / 1024, 0) & "KB" & vbCrLf
str1 += "已用空间:" & FormatNumber(drv1.TotalSize / 1024 - drv1.FreeSpace / 1024, 0) & "KB" & vbCrLf
Me.Label1.Text = str1