home *** CD-ROM | disk | FTP | other *** search
- ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ;
- ; DiskData.ASM - A QB4 FUNCTION to return data about a specified
- ; disk(ette) drive.
- ;
- ; Last Revised - 07/21/90 11:44am
- ;
- ; This FUNCTION should be DECLAREd in your source program as follows:
- ;
- ; DECLARE FUNCTION DiskData% (Drv%, SPC&, NAC&, BPS&, CPD&)
- ;
- ; where the passed parms are defined as follows:
- ;
- ; Drv% = an INTEGER value containing the value of the drive to be read,
- ; where 0 = the current default drive, 1 = A:, 2 = B:, etc
- ; SPC& = a LONG INT variable which will contain the number of sectors
- ; per cluster on the specified drive on return.
- ; NAC& = a LONG INT variable which will contain the number of available
- ; clusters on the drive on return.
- ; BPS& = a LONG INT variable which will contain the number of Bytes per
- ; sector on the drive on return.
- ; CPD& = a LONG INT variable which will contain the total number of
- ; clusters (whether used or not) on the drive on return.
- ;
- ; RETURNS An INT value which will be 0 if the drive was read
- ; successfully, or -1 if it could not be read.
- ;
- ; Common uses for the above data would include:
- ;
- ; 1. SPC& * BPS& = number of bytes per cluster on the disk
- ; 2. SPC& * BPS& * NAC& = number of bytes free on the drive
- ; 3. SPC& * BPS& * CPD* = total number bytes on disk (free or not)
- ; 4. (BPS& * 100) / CPD& = percent of drive space which is free
- ; 5. If S = the size of any given file in bytes, then we can determine
- ; how many drive sectors it requires by the following:
- ; (S + BPS& * SPC& - 1) / (BPS& * SPC*)
- ;
- ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- .MODEL MEDIUM,BASIC
- .CODE
-
- DiskData PROC DRV:word,SPC:word,NAC:word,BPS:word,CPD:word
-
- mov BX,DRV
- mov DX,[BX] ; DL = Drive code (0=default,1=A:,etc)
- mov AH,36h
- int 21h
- cmp AX,0FFFFh ; If error, RETURN with AX = -1
- je ExitDiskData
-
- push DX ; Store CPD for later use
- mov DX,BX ; Put NAC into DX
- mov BX,NAC ; Point BX at location of NAC variable
- mov [BX],DX ; Store # avail. clusters into NAC
- mov BX,SPC
- mov [BX],AX ; Store Sectors Per Cluster in SPC
- mov BX,BPS
- mov [BX],CX ; Store Bytes per Sector in BPS
- mov BX,CPD
- pop DX
- mov [BX],DX ; Store Clusters per drive in CPD
- xor AX,AX ; Indicate RETURN = 0 = no problems
-
- ExitDiskData:
-
- ret
-
- DiskData ENDP
- END
-
- ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++