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
'Path = "c:\" 指定Volume 代号, 如: c:\ d:\ e:\
Public Function GetFreeSpace(Byval Path as String) as Long
Dim aa As Long
Dim Path As String
Dim SecPerClust As Long
Dim BytePerSec As Long, FreeClust As Long, totClust As Long
Path = "c:\" '指定Volume 代号, 如: c:\ d:\ e:\
aa = GetDiskFreeSpace(Path, SecPerClust, BytePerSec, FreeClust, totClust)
GetFreeSpace = SecPerClust * BytePerSec * FreeClust
End Function
'Path = "c:\" 指定Volume 代号, 如: c:\ d:\ e:\
Public Function GetTotalSpace(Byval Path as String) as Long
Dim aa As Long
Dim Path As String
Dim SecPerClust As Long
Dim BytePerSec As Long, FreeClust As Long, totClust As Long
aa = GetDiskFreeSpace(Path, SecPerClust, BytePerSec, FreeClust, totClust)
GetTotalSpace = SecPerClust * BytePerSec * totClust
End Function
|