Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / QDrive.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=======================================================
' Type Objet
' Classe QDrive
'=======================================================
' GetDriveType return values
     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

     TYPE QDrive EXTENDS QOBJECT
      Name(26) AS STRING
      Count AS INTEGER PROPERTY SET SetCount

  '=========================================
  ' proprieté nombre de lecteur(read only)
  '=========================================
      PROPERTY SET SetCount(value AS INTEGER)
      END PROPERTY

  '=========================================
  ' méthode type de lecteur
  '=========================================
      FUNCTION GetType(index AS INTEGER) AS LONG
       IF index<=QDrive.Count THEN
        QDrive.GetType=GetDriveType(QDrive.Name(index))
       END IF
      END FUNCTION

  '=========================================
  ' méthode espace libre d'un lecteur
  '=========================================
      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

  '=========================================
  ' méthode taille d'un lecteur
  '=========================================
      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

  '=========================================
  ' méthode reception des lecteurs présents
  '=========================================
      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

  '-- Default values
      CONSTRUCTOR
       Count=0
       GetDrives
      END CONSTRUCTOR
     END TYPE
掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2001-12-18 08:36:12