Tag Archive: drive

get logical drives

!------------------------------------------------------------------------------------------
! inside the global map
!------------------------------------------------------------------------------------------
Module('WINAPI')
   GetLogicalDrives(),ULONG,PASCAL
   GetLogicalDriveStrings(LONG,*CSTRING),LONG,PASCAL,RAW,NAME('GetLogicalDriveStringsA')
   GetDriveType(*CSTRING),UNSIGNED,PASCAL,RAW,NAME('GetDriveTypeA')
END

!------------------------------------------------------------------------------------------
! DATA
!------------------------------------------------------------------------------------------
qDrive               QUEUE,PRE(qDrive)
Drive                CSTRING(5)
qDrive:Desciption    CSTRING(40)
Type                 BYTE
                     END
l:DrivesCString      CSTRING(200)
l:DrivesLen          LONG

!------------------------------------------------------------------------------------------
! CODE
!------------------------------------------------------------------------------------------
   l:DrivesDWORD   = GetLogicalDrives()
   l:DrivesLen     = 200
   l:DrivesCString = '<0>{200}'
   l:DrivesString  = ''
   clear(qDrive)
   free(qDrive)
   ret# = GetLogicalDriveStrings(l:DrivesLen,l:DrivesCString)
   loop i# = 1 to 200
     if val(l:DrivesCString[i#]) > 20 then
       qDrive:Drive = qDrive:Drive & l:DrivesCString[i#]
     else
       if qDrive:Drive then
         qDrive:Type = GetDriveType(qDrive:Drive)
         case qDrive:Type
           of 0;  qDrive:Desciption = 'The drive type cannot be determined.'
           of 1;  qDrive:Desciption = 'The root directory does not exist.'
           of 2;  qDrive:Desciption = 'removable drive'
           of 3;  qDrive:Desciption = 'fixed drive'
           of 4;  qDrive:Desciption = 'network drive'
           of 5;  qDrive:Desciption = 'CDROM drive'
           of 6;  qDrive:Desciption = 'ramdisk'
         end
         add(qDrive)
         clear(qDrive)
       end
     end
   end