Returns the total storage capacity for a drive
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long
Sub TotalDiskSpace()
Dim SectorsPerCluster As Long
Dim BytesPerSector As Long
Dim NumberofFreeClusters As Long
Dim TotalClusters As Long
x = GetDiskFreeSpace("c:\", SectorsPerCluster, _
BytesPerSector, NumberofFreeClusters, TotalClusters)
If x = 0 Then 'Error occurred
Exit Sub
End If
Debug.Print SectorsPerCluster
Debug.Print BytesPerSector
Debug.Print TotalClusters
End Sub
Related examples in the same category