[net.micro] How does a program detect disks on a PC?

lisa@phs.UUCP (Jeffrey William Gillette) (09/23/85)

[]

I have a program that needs to know how many disk drives [block devices] are 
present on an IBM PC / compatible.  I know that interrupt 11h (equipment 
check) will tell me about diskette drives, but I also need to find out about 
fixed diskes (which may be partitioned into more than one logical device) 
and other device drivers which are loaded through config.sys (e.g. Iomega 
Bernoulle boxes).  

Does anyone know of a way to check for the presence of block devices without
either asking the user (who in this case will probably not know the answer),
or making calls to DOS that will put strange error messages on the screen.

Jeffrey William Gillette		uucp: duke!phys!lisa
The Divinity School			bitnet: DYBBUK @ TUCCVM
Duke University

bet@ecsvax.UUCP (Bennett E. Todd III) (09/23/85)

(I'm moving this discussion to net.micro.pc -- that's where it belongs).
It appears to me, from reading the documentation, that the correct way
to determine how many disks DOS thinks there are is through the DOS
function call Select Disk (0E hex).
	mov	ah,19h	; Current disk -- returned in AL
	int	21h
	mov	dl,al
	mov	ah,0Eh	; set disk to that in DL -- returns total
	int	21h	; number available in AL
Unfortunately, the number DOS is returning seems to bear little
relationship to the number of disk devices DOS currently knows about.
Running DOS 3.10 on an IBM-PC/XT I get 5 drives. This doesn't change
whether or not I have my ramdisk device driver installed. Does this call
work correctly in any version of DOS? Is the number it returns useful
for anything? Is there a correct way to find out how many disk devices
DOS knows about? And what about ... Naomi!!!

-Bennett
-- 

"Hypocrisy is the vaseline of social intercourse." (Who said that?)

Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695
UUCP: ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!duccpc!bet

dan@gumby.UUCP (09/27/85)

> Unfortunately, the number DOS is returning seems to bear little
> relationship to the number of disk devices DOS currently knows about.
> Running DOS 3.10 on an IBM-PC/XT I get 5 drives. This doesn't change
> whether or not I have my ramdisk device driver installed. Does this call
> work correctly in any version of DOS? Is the number it returns useful
> for anything?

I suspect the number you are getting is the number of the highest
available drive letter.  Huh?, you ask?  As of version 3.1, DOS
reserves some extra drive letters for you to assign to pathnames
using the subst command.  The default highest drive letter is E:,
thus the number 5.  There is a command for the config.sys file to
raise or lower that number; it cannot be made lower than the number
of installed drives (including RAM drives, I think).

Check page 4-24 of the DOS 3.1 manual for a description of the 
LASTDRIVE command.