Espace disque libre

 

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


Public Sub DonnerEspaceDisque(ByVal Disque As String, EspaceTotal As Long, EspaceLibre As Long)
Dim numSectorsPerCluster As Long
      Dim numBytesPerSector As Long
      Dim numFreeClusters As Long
      Dim numTotalClusters As Long
      Dim free_Space As Long
      Dim total_Space As Long
      Dim success As Boolean
      success = GetDiskFreeSpace(Disque, numSectorsPerCluster, numBytesPerSector, numFreeClusters, numTotalClusters)
      free_Space = numSectorsPerCluster * numBytesPerSector * numFreeClusters
      total_Space = numSectorsPerCluster * numBytesPerSector * numTotalClusters
      EspaceLibre = free_Space / 1024
      EspaceTotal = total_Space / 1024
End Sub



UTILISATION :
    DonnerEspaceDisque "c:\", EspaceTotal, EspaceLibre
    msgbox "" & EspaceTotal  & "-" &  EspaceLibre