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
Private Sub cGetDiskFreeSpace()
Dim SectorsPerCluster&, BytesPerSector&, FreeClusters&
Dim TotalClusters&, FreeSpace$, Success As Boolean, Drive$
Drive = UCase(Left(App.Path, 3))
Success = GetDiskFreeSpace(Drive, SectorsPerCluster, BytesPerSector, FreeClusters, TotalClusters)
FreeSpace = SectorsPerCluster * BytesPerSector * FreeClusters
FreeSpace = (FreeSpace \ 1024) \ 1024
MsgBox "Свободно на текущем диске " & Drive & Str$(FreeSpace) & " мегабайт", vbOKOnly + vbInformation
End Sub
Private Sub Form_Load()
cGetDiskFreeSpace
End Sub |
|