[comp.os.msdos.programmer] Drive detection code.

a563@mindlink.UUCP (Dave Kirsch) (09/06/90)

There was some code posted to this group on obtaining whether a drive is
actually accessable or not (i.e. the DOS call setdrive may return 5 drives, but
in actual fact there is 4).

Anyone got this code?  Would appreciate it if you could mail me a copy.
--
--
David Kirsch          UUCP: {uunet,ubc-cs}!van-bc!rsoft!mindlink!a563
Voice: (604) 327-4404       a563@mindlink.UUCP
                      Vancouver, British Columbia
'In-no-sense?  Nonsense!' - The Art Of Noise

a563@mindlink.UUCP (Dave Kirsch) (09/10/90)

In article <2100@cod.NOSC.MIL> bmarsh@cod.NOSC.MIL (William C. Marsh) writes:
> 
> In article <3081@mindlink.UUCP> a563@mindlink.UUCP (Dave Kirsch) writes:
> >There was some code posted to this group on obtaining whether a drive is
> >actually accessable or not (i.e. the DOS call setdrive may return 5 drives,
> but
> >in actual fact there is 4).
> >
> >Anyone got this code?  Would appreciate it if you could mail me a copy.
> 
> Here is a simple function I have used to detect valid drives.  It will
> work under DOS 3.X and higher, using the IOCTL function to detect
> removable/fixed disks.
> 
> [ code deleted ]

I was hoping for one that ran under DOS 2.0 and later.  Anyone got one that
will work under DOS 2?
--
--
David Kirsch          UUCP: {uunet,ubc-cs}!van-bc!rsoft!mindlink!a563
Voice: (604) 327-4404       a563@mindlink.UUCP
                      Vancouver, British Columbia
'In-no-sense?  Nonsense!' - The Art Of Noise

bmarsh@cod.NOSC.MIL (William C. Marsh) (09/11/90)

In article <3081@mindlink.UUCP> a563@mindlink.UUCP (Dave Kirsch) writes:
>There was some code posted to this group on obtaining whether a drive is
>actually accessable or not (i.e. the DOS call setdrive may return 5 drives, but
>in actual fact there is 4).
>
>Anyone got this code?  Would appreciate it if you could mail me a copy.

Here is a simple function I have used to detect valid drives.  It will 
work under DOS 3.X and higher, using the IOCTL function to detect
removable/fixed disks.

-------

#include <dos.h>

drive_valid(int drive)
{
	union REGS	regs, oregs;

	regs.x.ax = 0x4408;	/* Test for drive valid by testing for	*/
				/* removable/fixed drive status		*/ 
	regs.h.bl = drive + 1;

	intdos(&regs, &oregs);

	if(oregs.x.ax != 0x000F)	/* If not invalid, return true	*/
		return(1);

	return(0);
}
-- 
Bill Marsh, Naval Ocean Systems Center, San Diego, CA
{arpa,mil}net: bmarsh@cod.nosc.mil
uucp: {ihnp4,akgua,decvax,dcdwest,ucbvax}!sdcsvax!nosc!bmarsh
"If everything seems to be coming your way, you're probably in the wrong lane."