[comp.os.msdos.programmer] Checking for disk characteristics

arasmith@mathcs.emory.edu (David Arasmith) (09/13/90)

   I have a question for those out there more knowledgable than myself.
I am trying to determine the number of logical hard drives on any garden
variety IBM PC or PS/2 from within Turbo C(++ v1.0).  I cannot assume
that functions such as setdisk() will give reliable information.

  What I need is a way to check a particular drive without encountering
the infamous Abort, Retry, Fail.  Does someone out there know an easy
way to poke a drive (and determine if it is fixed or floppy) without
forcing a user to insert a floppy?  (I'm not worried about a: & b: - it's
the d:'s e:'s and f:'s hanging off the back that concern me!)

Thanks a lot!  Email is more likely to get to me (actually me to it).
-- 
David M. Arasmith   |  arasmith@mathcs.emory.edu	        Internet
Emory University    |  {sun!sunatl,gatech}!emory!arasmith	UUCP
Dept of Math and CS |  
Atlanta, GA 30322   |  I should be working!  Gee....I wonder what's on TV?

PA163514@tecmtyvm.mty.itesm.mx (09/16/90)

Sorry, but I wrote


Good, Luck.

phys169@canterbury.ac.nz (09/20/90)

In article <90257.135612PA163514@tecmtyvm.mty.itesm.mx>, PA163514@tecmtyvm.mty.itesm.mx writes:
> Arasmith,
> 
> TOPIC:  How many disk drives are in your PC?
> 
> These are the steps:
:
> 4. Get value in Port 60h
..etc...

That isn't always going to solve the original problem, of finding the number of 
hard drives without waiting for a floppy, but it does find the number of
diskettes from the dip switches on a PC okay, although int 11h would be much
better, as far as compatibility is concerned, or even peeking at location 410h,
i.e. NumberOfDiskettes:=(memw[$40:$10] and 1)*(1+(mem[$40:$10]and 3) shr 6).

The number of *physical* hard drives can be found in most PC/XT/AT compatibles
at byte 475h (mem[$40:$75] in Turbo Pascal), but that doesn't allow for logical
drives, nor does using int 13h with AH=15h, DL=80h+each drive number to test.

The "proper" method is to ask DOS via int 21h, AX=4408, and BL varying from 1
to the highest likely drive number (say 26); the result is: carry flag on means
an invalid drive, otherwise AX=1 means a fixed disk - which might be a network
drive, so you could test if bit 12 of DX is 0 (DOS call 4409h), if that is a
possibility you need to check. Unfortunately, this requires DOS 3 or above.
If you must use DOS 2, use the number at location 475h, rememberring the first
hard drive letter will be "C" in DOS if you are on a PC, or higher on a PC/XT
if the number of diskettes is >2, or lower if running on a DG10 with only one
diskette drive (but who uses them nowadays??).

Hope this helps,
Mark Aitchison, Physics, University of Canterbury, New Zealand.