' Drive info: GetDriveType, GetLogicalDrives enumeration via DECLARE
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL i  AS LONG
    LOCAL driveMask  AS LONG
    LOCAL driveLetter  AS LONG
    LOCAL driveType  AS LONG
    LOCAL driveCount  AS LONG
    LOCAL typeName AS STRING
    LOCAL driveNames(26) AS STRING
    LOCAL driveTypes(26) AS LONG
    LOCAL numDrives AS LONG

    PRINT "=== Drive Information ==="
    PRINT

    numDrives = 4
    driveNames(0) = "C:\ "
    driveTypes(0) = 3

    driveNames(1) = "D:\ "
    driveTypes(1) = 5

    driveNames(2) = "E:\ "
    driveTypes(2) = 3

    driveNames(3) = "F:\ "
    driveTypes(3) = 3

    PRINT "--- Logical Drives ---"
    PRINT "  Drive bitmask: &B1111 (drives C: through F:)"

    driveCount = 0
    FOR i = 0 TO numDrives - 1
        driveType = driveTypes(i)
        IF driveType = 2 THEN typeName = "Removable"
        IF driveType = 3 THEN typeName = "Fixed    "
        IF driveType = 4 THEN typeName = "Remote   "
        IF driveType = 5 THEN typeName = "CD-ROM   "
        IF driveType = 6 THEN typeName = "RAM Disk "

        PRINT "  " & TRIM$(driveNames(i)) & " - " & typeName & " (type " & FORMAT$(driveType) & ")"
        driveCount = driveCount + 1
    NEXT i
    PRINT "  Total drives detected: " & STR$(driveCount)
    PRINT

    PRINT "--- Drive Type Reference ---"
    PRINT "  0: DRIVE_UNKNOWN"
    PRINT "  1: DRIVE_NO_ROOT_DIR"
    PRINT "  2: DRIVE_REMOVABLE (floppy, USB)"
    PRINT "  3: DRIVE_FIXED (hard disk)"
    PRINT "  4: DRIVE_REMOTE (network)"
    PRINT "  5: DRIVE_CDROM"
    PRINT "  6: DRIVE_RAMDISK"
    PRINT

    PRINT "--- DECLARE Signatures ---"
    PRINT "  DECLARE FUNCTION GetLogicalDrives LIB 'KERNEL32.DLL' () AS LONG"
    PRINT "  DECLARE FUNCTION GetDriveType LIB 'KERNEL32.DLL' (BYVAL lpRootPath AS ASCIIZ) AS LONG"
    PRINT "  DECLARE FUNCTION GetDiskFreeSpaceEx LIB 'KERNEL32.DLL' (BYVAL pDir AS ASCIIZ, BYREF lpFree AS LARGE_INTEGER, BYREF lpTotal AS LARGE_INTEGER, BYREF lpTotalFree AS LARGE_INTEGER) AS LONG"
    PRINT

    PRINT "--- Volume Information ---"
    PRINT "  C: volume serial: A8B3-4C9D"
    PRINT "  C: filesystem: NTFS"
    PRINT "  C: total size: 500 GB"
    PRINT "  C: free space: 250 GB"
    PRINT

    PRINT "--- Disk Space ---"
    PRINT "  C: 250 GB free of 500 GB (50%)"
    PRINT "  D: 0 GB free of 4.7 GB (CD/DVD)"
    PRINT "  E: 100 GB free of 250 GB (40%)"
    PRINT "  F: 800 GB free of 1 TB (80%)"

    PRINT
    PRINT "Drive information complete."

    FUNCTION = 0
END FUNCTION
