'引用 Microsoft Scripting Runtime
Dim x As New Scripting.FileSystemObject
Dim y As Scripting.Drive
For Each y In x.Drives
Debug.Print y.DriveType
If y.DriveType = Fixed Then
Debug.Print "AvailableSpace: " & y.AvailableSpace / 1024 / 1024 & " MBytes"
Debug.Print "DriveLetter: " & y.DriveLetter
Debug.Print "DriveType: " & y.DriveType
Debug.Print "FileSystem: " & y.FileSystem
Debug.Print "FreeSpace: " & y.FreeSpace / 1024 / 1024 & " MBytes"
Debug.Print "IsReady: " & y.IsReady
Debug.Print "Path: " & y.Path
Debug.Print "RootFolder: " & y.RootFolder
Debug.Print "SerialNumber: " & y.SerialNumber
Debug.Print "ShareName: " & y.ShareName
Debug.Print "TotalSize: " & y.TotalSize / 1024 / 1024 & " MBytes"
Debug.Print "VolumeName: " & y.VolumeName
End If
Next
Dim x As New Scripting.FileSystemObject
Dim y As Scripting.Drive
For Each y In x.Drives
Debug.Print y.DriveType
If y.DriveType = Fixed Then
Debug.Print "AvailableSpace: " & y.AvailableSpace / 1024 / 1024 & " MBytes"
Debug.Print "DriveLetter: " & y.DriveLetter
Debug.Print "DriveType: " & y.DriveType
Debug.Print "FileSystem: " & y.FileSystem
Debug.Print "FreeSpace: " & y.FreeSpace / 1024 / 1024 & " MBytes"
Debug.Print "IsReady: " & y.IsReady
Debug.Print "Path: " & y.Path
Debug.Print "RootFolder: " & y.RootFolder
Debug.Print "SerialNumber: " & y.SerialNumber
Debug.Print "ShareName: " & y.ShareName
Debug.Print "TotalSize: " & y.TotalSize / 1024 / 1024 & " MBytes"
Debug.Print "VolumeName: " & y.VolumeName
End If
Next
在采用FAT16格式的windows95系统中,如一个驱动器(分区)的容量超过了2GB,则不应使用这个函数。此时,这个函数能识别的最大分区容量只有2GB