Dim FB, BT, FBT As Currency
Dim DriveSize As String Const Gigabyte = 1073741824 Const Megabyte = 1048576 Dim retval As Long Private Declare Function GetDiskFreeSpace_FAT32 _ Lib "kernel32" Alias "GetDiskFreeSpaceExA" _ (ByVal lpRootPathName As String, _ FreeBytesToCaller As Currency, BytesTotal _ As Currency, FreeBytesTotal As Currency) _ As Long Public Function GetDriveInfo(DriveName As String) As String retval = GetDiskFreeSpace_FAT32(Left(DriveName, 2), FB, BT, FBT) FBT = FBT * 10000 'convert result To actual size In bytes If FBT / Gigabyte < 1 Then 'If less than 1GB then show as MB DriveSize = Format(FBT / Megabyte, "####,###,###") & " MB free" Else 'Show as GB DriveSize = Format(FBT / Gigabyte, "####,###,###.00") & " GB free" End If GetDriveInfo = "[" & DriveSize & "]" End Function |