:: How to Calculate the Amount of Free Disk Space Available... |
Author |
Andrea Tincani |
Language |
VB5, VB6 |
Operating
Systems |
Windows 95, 98 and NT |
API
Declarations |
'API Declarations
Private Declare Function GetDiskFreeSpace Lib "kernel32.dll" Alias "GetDiskFreeSpaceA"
(ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long,
lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long |
Module |
'Call this function to get the Amount of Free Disk Space
(in Bytes)
'Pass to this function only the letter of the drive
Function FreeDiskSpace(DriveLetter As String)
Dim SectorsPerCluster As Long
Dim BytesPerSector As Long
Dim FreeClusters As Long
Dim NumberOfClusters As Long
Dim ret As Long
ret = GetDiskFreeSpace(DriveLetter & ":\",
SectorsPerCluster, BytesPerSector, FreeClusters, NumberOfClusters)
FreeDiskSpace = BytesPerSector * SectorsPerCluster * FreeClusters
End Function |
Usage |
'Simple use of the function
Private Sub Command1_Click()
MsgBox FreeDiskSpace("C") \ 1024 & " Kb Free Space
in Drive C"
End Sub |
|
|
|
|