🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #2145

Re: Drive detection code.

#2145
From: William C. Marsh
Date: Mon, 10 Sep 1990 19:38
35 lines
1507 bytes
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."
Technical Details
Message-ID: <2100@cod.NOSC.MIL>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!ucsd!nosc!cod!bmarsh
References: <3081@mindlink.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!ucsd!nosc!cod!bmarsh
From: bmarsh@cod.NOSC.MIL (William C. Marsh)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Drive detection code.
Message-ID: <2100@cod.NOSC.MIL>
Date: 10 Sep 90 19:38:36 GMT
References: <3081@mindlink.UUCP>
Reply-To: bmarsh@cod.nosc.mil.UUCP (William C. Marsh)
Organization: Naval Ocean Systems Center, San Diego
Lines: 35