BBS: Inland Empire Archive Date: 01-16-93 (14:49) Number: 354 From: MATT HART Refer#: NONE To: KEITH WATKINS Recvd: NO Subj: DISK SIZE Conf: (2) Quik_Bas
KW> Someone had posted code to not only see how much room was left on a disk KW> but how big the disk room was in total. I did not need it then KW> but I do now. Would someone repost it? Thanks. -Keith ' FREESPAC.BAS Matt Hart ' ' Start QB or QBX with /L to load the QB.QLB or ' QBX.QLB library ' ' Free disk space with Interrupt 21h Function 36h '$INCLUDE:'\BC71\QBX.BI' ' Replace with your path to ' QBX.BI or QB.BI DEFINT A-Z DECLARE FUNCTION FreeSpace&(Drv%) DIM SHARED InRegs AS RegTypeX DIM SHARED OutRegs AS RegTypeX ' ------ Test code Drv = ASC(LTRIM$(RTRIM$(COMMAND$))+CHR$(64)) - 64 IF Drv = 0 THEN D$ = "Current" ELSE D$ = CHR$(Drv+64) PRINT D$+" Drive's Free Space is";FreeSpace&(Drv) END ' ---------------- FUNCTION FreeSpace&(Drv) InRegs.AX = &H3600 InRegs.DX = Drv CALL InterruptX(&H21,InRegs,OutRegs) IF OutRegs.AX = &HFFFF THEN FreeSpace& = 0& ' Drive Invalid ELSE SPC& = OutRegs.AX ' Sectors per cluster IF SPC& < 0& THEN SPC& = 65536& + SPC& AVC& = OutRegs.BX ' Available clusters IF AVC& < 0& THEN AVC& = 65536& + AVC& BPS& = OutRegs.CX ' Bytes per sector IF BPS& < 0& THEN BPS& = 65536& + BPS& FreeSpace& = SPC& * AVC& * BPS& ENDIF END FUNCTION ' DISKSIZE.BAS Matt Hart ' ' Uses Int 21h Function 1Ch to get the disk size ' DriveNum% is 0 for current drive, or ' A: = 1 to Z: = 26 ' ' Added FUNCTION UnSigned& to convert a possible word of greater ' than 32768 to a positive number. '$INCLUDE: 'qb.bi' DEFINT A-Z DECLARE FUNCTION DiskSize&(DriveNum) DECLARE FUNCTION UnSigned&(Num) DIM SHARED InRegs AS RegTypeX DIM SHARED OutRegs AS RegTypeX PRINT DiskSize&(0) END FUNCTION DiskSize&(DriveNum) InRegs.AX = &H1C00 InRegs.DX = DriveNum CALL InterruptX(&H21, InRegs, OutRegs) SecPerClu& = UnSigned&(OutRegs.AX) MOD 256 BytPerSec& = UnSigned&(OutRegs.CX) CluPerDis& = UnSigned&(OutRegs.DX) DiskSize& = (SecPerClu& * BytPerSec& * CluPerDis&) END FUNCTION FUNCTION UnSigned&(Num) IF Num < 0 THEN UnSigned& = 65536& + Num ELSE UnSigned& = Num ENDIF END FUNCTION --- * Origin: Midnight Micro! V.32/REL (918)451-3306 (1:170/600)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET