Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
GetDiskSize
 Map                                       Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
;* GetDiskSize - Gets size information from specified disk.
;*
;* Shows:   DOS Function - 36h (Get Drive Allocation Information)
;*
;* Params:  Drive - Drive code (0 = default, 1 = A, 2 = B, etc.)
;*          Disk  - Pointer to a structure with 4 short integer members:
;*                      Member 1 - Total clusters on disk
;*                      Member 2 - Number of available clusters
;*                      Member 3 - Sectors/cluster (-1 if invalid drive)
;*                      Member 4 - Bytes/sector
;*
;* Return:  None
 
GetDiskSize PROC USES di,
        Drive:WORD, Disk:PDISKSTAT
 
        mov     dx, Drive               ; DL = drive code
        mov     ah, 36h                 ; DOS Function 36h
        int     21h                     ; Get Drive Allocation Information
        LoadPtr es, di, Disk            ; ES:DI = disk structure
        mov     (DISKSTAT PTR es:[di]).\
                total, dx               ; DX = total clusters
        mov     (DISKSTAT PTR es:[di]).\
                avail, bx               ; BX = number of free clusters
        mov     (DISKSTAT PTR es:[di]).\
                sects, ax               ; AX = sectors/cluster
        mov     (DISKSTAT PTR es:[di]).\
                bytes, cx               ; CX = bytes/sector
        ret
 
GetDiskSize ENDP
                                    -♦-