delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/29/03:55:23

Xref: news2.mv.net comp.os.msdos.djgpp:623
From: malcolm AT manawatu DOT gen DOT nz (Malcolm Taylor)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Finding which drives exist
Date: Tue, 23 Jan 1996 22:15:23 GMT
Organization: Grafik Software
Lines: 33
Message-ID: <4e3iok$i5b@news.manawatu.gen.nz>
References: <DLFvGL DOT 8xJ AT jade DOT mv DOT net>
Reply-To: malcolm AT manawatu DOT gen DOT nz
NNTP-Posting-Host: malcolm.manawatu.gen.nz
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk> wrote:

>be written to. But this is unsatisfactory. Please how in Gnu C++ can I find
>easily at run time for(i='A';i<='Z';i++) whether drive i exists? And I don't
>want in the process any empty floppy or CD-ROM drives making rude noises at me
>or wanting Abort/Fail/Retry. I don't mind if an empty floppy drive is treated
>as nonexistent. It seems easy enough: the File Manager in Windows gets it
>right every time and displays across the top of its window a row of little
>disk drive icons, one for each existing logical drive.

It is much harder than you may think. DOS doesn't seem to have any way
to reliably check for drives, but I have managed to piece together a
fairly good system from the Ralph Brown interrupt list (if you haven't
already got this then ftp it from simtel).
	To find out the floppy info I use int 0x13 func 8 which gives me the
number of floppies on the system. Then to get info for the CDRom dives
use int 0x2f func ax=0x1500. This gives the number of CDRoms and the
first letter used. Then the hard drives can be found by the normal
setdisk(), getdisk() loop. You do this test on all drives not floppies
or CDRoms and setdisk to the number, and the drive exists if getdisk
returns the same number.
	I set up a function to do all these tests when the program is booted,
and store the list for use later. To test for a drive ready I find the
easiest is to do a findfirst on the floppy (easiest to test for a
volume label). If this fails then there is no disk in the drive. For a
CDRom it was a little harder, I used int 0x2f with ax=0x1505 (using
the transfer buffer).
	I can't say though whether this works under netware or not. It is
successful on DOS, Win 3.11, and Win95 though.

Hope this helps
Malcolm

- Raw text -


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