Disk Space

 BBS: Inland Empire Archive
Date: 01-06-93 (08:04)             Number: 335
From: GLENN DELAHOY                Refer#: NONE
  To: MARK WITTKOSKI                Recvd: NO  
Subj: Disk Space                     Conf: (2) Quik_Bas
 > How can I find out much space I have on an available disk.

FUNCTION GetFreeSpace& (Drive, DiskSize&)
DIM InRegs AS RegType, OutRegs AS RegType

' get disk free space - Drive 0 is current drive
InRegs.ax = &H3600
InRegs.dx = Drive
CALL Interrupt(&H21, InRegs, OutRegs)

        IF OutRegs.ax = &HFFFF THEN
        ' invalid drive specified
        GetFreeSpace& = -1
        ELSE
        a& = CLNG(OutRegs.ax) * CLNG(OutRegs.bx) * CLNG(OutRegs.cx)
        DiskSize& = CLNG(OutRegs.ax) * CLNG(OutRegs.cx) * CLNG(OutRegs.dx)
        GetFreeSpace& = a&
        END IF

' returns
' ax = number sectors per cluster
'      or &HFFFF if invalid drive
' bx = number available clusters
' cx = bytes per sector
' dx = total clusters
'
' ax * bx * cx = total free space
' ax * cx * dx = total disk space

END FUNCTION

Regards,

Glenn





 >    --Mark

 > --- Maximus 2.01wb
 >  * Origin: |=[Bloom Co. Hospital>=--- |[GRapids,MI]
 > (616)361-8345 (1:228/26)

--- FMail 0.92
 * Origin: Rough Productions -V32- (059) 983 639 (3:635/572)
Outer Court
Echo Basic Postings

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