Basic Univers
Procedure.l GetDiskFreeSpace(lecteur.s, type.l)
  ; lecteur = nom du lecteur
  ; type = choix de la réponse, 0 = espace libre sur le lecteur, 1 = taille du lecteur
  
  Protected val.l
  Protected txt.s
  
  Memory1 = AllocateMemory(1, 5, 0)
  Memory2 = AllocateMemory(2, 5, 0)
  Memory3 = AllocateMemory(3, 5, 0)
  GetDiskFreeSpaceEx_(lecteur + ":\", Memory1 , Memory2, Memory3)
  
  Select type
    Case 0 : Memory1 + 1 : CopyMemory(Memory1, @size.l, 4)
    Case 1 : Memory2 + 1 : CopyMemory(Memory2, @size.l, 4)
  EndSelect
  
  size = size / 4
  
  ProcedureReturn size
  
EndProcedure

Procedure.s GetDiskFreeSpaceEx(lecteur.s, type.l, unit.l, approximation.l, auto.l)
  ; lecteur = nom du lecteur
  ; type = choix de la réponse, 0 = espace libre sur le lecteur, 1 = taille du lecteur
  ; unit = unité de la taille, 0 = Ko, 1 = Mo, 2 = Go
  ; approximation = nombre de chiffre après la virgule
  ; si auto = 1, choix de l'unité automatique et approximation automatique
  
  Protected val.l
  Protected txt.s
  
  Memory1 = AllocateMemory(1, 5, 0)
  Memory2 = AllocateMemory(2, 5, 0)
  Memory3 = AllocateMemory(3, 5, 0)
  GetDiskFreeSpaceEx_(lecteur + ":\", Memory1 , Memory2, Memory3)
  
  Select type
    Case 0 : Memory1 + 1 : CopyMemory(Memory1, @size.l, 4)
    Case 1 : Memory2 + 1 : CopyMemory(Memory2, @size.l, 4)
  EndSelect
  
  size = size / 4
  
  If auto
    approximation = 0 : unit = 0
    If size >= 1000 : unit = 1 : approximation = 2 : EndIf
    If size >= 10000 : unit = 1 : approximation = 1 : EndIf
    If size >= 1000000 : unit = 2 : approximation = 2 : EndIf
    If size >= 10000000 : unit = 2 : approximation = 1 : EndIf
  EndIf
  Select unit
    Case 1 : val = 1024 : txt = " Mo"
    Case 2 : val = 1024 * 1024 : txt = " Go"
    Default : val = 1 : txt = " Ko"
  EndSelect
  ProcedureReturn StrF(size / val, approximation) + txt
  
EndProcedure



Debug GetDiskFreeSpace("c", 1)
Debug GetDiskFreeSpaceEx("c", 1, 0, 0, 1)