Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Detect the available drives on DOS (Developers)

posted by CandyMan, 07.07.2023, 21:41

You set the default disk (function 0Eh) and then check if the default is the one you set (function 19h).

function DriveValid(Drive:Char):Boolean;
assembler;asm
        MOV     CL,Drive
        MOV     AH,$19
        INT     $21
        MOV     BL,AL
        MOV     DL,CL
        SUB     DL,'A'
        MOV     AH,$0E
        INT     $21
        MOV     AH,$19
        INT     $21
        XOR     CL,CL
        CMP     AL,DL
        JNE     @@1
        MOV     CL,1
        MOV     DL,BL
        MOV     AH,$0E
        INT     $21
@@1:    XCHG    EAX,ECX
end;

--------D-2119-------------------------------
INT 21 - DOS 1+ - GET CURRENT DEFAULT DRIVE
        AH = 19h
Return: AL = drive (00h = A:, 01h = B:, etc)
Note:   Novell NetWare uses the fact that DOS 2.x COMMAND.COM issues this call
          from a particular location every time it starts a command to
          determine when to issue an automatic EOJ
--------D-210E-------------------------------
INT 21 - DOS 1+ - SELECT DEFAULT DRIVE
        AH = 0Eh
        DL = new default drive (00h = A:, 01h = B:, etc)
Return: AL = number of potentially valid drive letters
Notes:  under Novell NetWare, the return value is always 32, the number of
          drives that NetWare supports
        under DOS 3.0+, the return value is the greatest of 5, the value of
          LASTDRIVE= in CONFIG.SYS, and the number of drives actually present
        on a DOS 1.x/2.x single-floppy system, AL returns 2 since the floppy
          may be accessed as either A: or B:
        otherwise, the return value is the highest drive actually present
        DOS 1.x supports a maximum of 16 drives, 2.x a maximum of 63 drives,
          and 3+ a maximum of 26 drives
        under Novell DOS 7, this function returns the correct LASTDRIVE value
          even when the undocumented LASTDRIVE=27..32 directive was used in
          CONFIG.SYS
        "parse FCB" (see AH=29h) can be used to determine whether a drive
          letter is valid

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 30 users online (0 registered, 30 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum