Path: 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 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 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(®s, &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."