Private Declare Function GetDiskFreeSpace Lib "kernel32" _
Alias "GetDiskFreeSpaceA" _
(ByVal lpRootPathName As String, _
lpSectorsPerCluster As Long, _
lpBytesPerSector As Long, _
lpNumberOfFreeClusters As Long, _
lpTotalNumberOfClusters As Long) As Long
' Get the free space.
Private Sub GetFreeSpace(ByVal drive_letter As String, _
ByRef total_size As Double, ByRef total_free As Double)
If GetDiskFreeSpace(drive_letter & ":\", _
sectors_per_cluster, _
bytes_per_sector, _
num_free_clusters, _
total_clusters) _
Then
total_size = total_clusters * sectors_per_cluster * _
bytes_per_sector
total_free = num_free_clusters * _
sectors_per_cluster * bytes_per_sector
Else
total_size = 0
total_free = 0
End If
End Sub
Private Sub Form_Load()
cbdrive.ListIndex = 0
End Sub
Private Sub Timer1_Timer()
Dim TotSize As Double
Dim TotFree As Double
' do something
GetFreeSpace cbdrive.Text, TotSize, TotFree
If (TotFree / 1024) / 1024 < CLng(Txtsize) Then
frmTip.Show
End If
End Sub
|