$IFNDEF __WIN32API
CONST DRIVE_REMOVABLE=2
CONST DRIVE_FIXED=3
CONST DRIVE_REMOTE=4
CONST DRIVE_CDROM=5
CONST DRIVE_RAMDISK=6
DECLARE FUNCTION GetDriveType LIB "kernel32" ALIAS "GetDriveTypeA" (nDrive AS STRING) AS LONG
DECLARE FUNCTION GetDiskFreeSpace LIB "kernel32" ALIAS "GetDiskFreeSpaceA" (root AS STRING,BYREF sectors AS LONG,BYREF bytes AS LONG,BYREF clusters AS LONG,BYREF total AS LONG) AS INTEGER
$ENDIF
TYPE QDrive EXTENDS QOBJECT
Name(26) AS STRING
Count AS INTEGER PROPERTY SET SetCount
PROPERTY SET SetCount(value AS INTEGER)
END PROPERTY
FUNCTION GetType(index AS INTEGER) AS LONG
IF index<=QDrive.Count THEN
QDrive.GetType=GetDriveType(QDrive.Name(index))
END IF
END FUNCTION
FUNCTION GetFreeSpace(index AS INTEGER) AS LONG
DIM SectorsPerCluster AS INTEGER
DIM BytesPerSector AS INTEGER
DIM NumberOfFreeClusters AS INTEGER
DIM TotalClusters AS INTEGER
DIM value AS INTEGER
IF index<=QDrive.Count THEN
value=GetDiskFreeSpace(QDrive.Name(index),SectorsPerCluster,BytesPerSector,NumberOfFreeClusters,TotalClusters)
IF value<>0 THEN
QDrive.GetFreeSpace=SectorsPerCluster*BytesPerSector*NumberOfFreeClusters
END IF
END IF
END FUNCTION
FUNCTION GetSize(index AS INTEGER) AS LONG
DIM SectorsPerCluster AS INTEGER
DIM BytesPerSector AS INTEGER
DIM NumberOfFreeClusters AS INTEGER
DIM TotalClusters AS INTEGER
DIM value AS INTEGER
IF index<=QDrive.Count THEN
value=GetDiskFreeSpace(QDrive.Name(index),SectorsPerCluster,BytesPerSector,NumberOfFreeClusters,TotalClusters)
IF value<>0 THEN
QDrive.GetSize=SectorsPerCluster*BytesPerSector*TotalClusters
END IF
END IF
END FUNCTION
SUB GetDrives
DIM ASC_A AS INTEGER
DIM ASC_Z AS INTEGER
DIM i AS INTEGER
DIM index AS INTEGER
index=0
ASC_A=65
ASC_Z=ASC_A+25
FOR i=ASC_A TO ASC_Z
IF GetDriveType(CHR$(i)&":\")<>1 THEN
index=index+1
QDrive.Count=QDrive.Count+1
QDrive.Name(index)=CHR$(i)+":\"
END IF
NEXT i
END SUB
CONSTRUCTOR
Count=0
GetDrives
END CONSTRUCTOR
END TYPE
|