www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/24/03:45:10

Date: Mon, 24 Feb 1997 10:30:35 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Delong <dandelong AT osha DOT igs DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Detecting all system drives ... how?
In-Reply-To: <3310E86E.176F@osha.igs.net>
Message-ID: <Pine.SUN.3.91.970224102958.3675H-100000@is>
MIME-Version: 1.0

On Sun, 23 Feb 1997, Delong wrote:

> I can't seem to find a way to detect all drives attached to the
> computer. I don't care about network drives. I'd like to tell the
> difference between B: actually existing or just A: being referenced as
> A: or B: but thats no big deal.
> 
> Is there a way to simply get a yes/no response to whether a drive (being
> either a number from 0-26 or letter from A-Z) is attached?

Please define ``attached''.  Your message doesn't explain why do you
need to know about ``all drives attached to the computer'', and
without such an explanation, it is very hard to suggest a suitable
solution.

If you only need to know when B: is a real drive (as opposed to an
alias for A: on single-floppy systems), then function 440Eh of Int 21h
is what you need (you can look it up in Ralf Brown's Interrupt List,
file INTERRUP.E; the file src/libc/compat/mntent/mntent.c in the DJGPP
source distribution djlsr201.zip has an example of using that
function).

However, you also say that you want to know about all the 26 drives,
and that you don't care about network drives, which confuses things.
On a typical PC, most of the drive letters beyond D: are network
drives, CD-ROMs, RAM disks or logical partitions of physical drives.
It is not clear which ones interest you and which don't.

If you just need to display to the user the drives that they can
change to, you might just try setting Z: as your default drive with
function 0Eh of Int 21h; it will return in the AL register the number
of ``potentially valid drive letters'' (to quote the Interrupt List).
But beware: that return value is the greatest of 5, the value of
LASTDRIVE= in CONFIG.SYS, and the number of drives actually present,
so if the user sets LASTDRIVE=Z, you get 26 even if Z isn't available.

(And BTW, DOS allows for a maximum of 32 drives, not 26; Novel Netware
is one case where that capability is actually used.)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019