erck12@castle.ed.ac.uk (Gnome) (09/07/89)
Here is one for the hackers among you! I want to poll a given (i.e. not necasarily physical) drive, given a drive letter supplied by the user. I want to find out if it is present, and functional without generating any DOS "retry, abort or ..." or "insert diskette for drive X" type messages. I am working in MSC 5.1. How would I go about it? -- Geoff Ballinger, JANET: Geoff@Ed.Ac.Uk CS/AI, ARPA: Geoff%Uk.Ac.Ed@nsfnet-relay.Ac.Uk Edinburgh University. UUCP: ...!uunet!mcvax!ukc!Ed.Ac.Uk!Geoff
slimer@trsvax.UUCP (09/08/89)
What you would want to do is this...
union REGS inregs, outregs;
char drive_value;
main()
{
/* Set up for IOCTL Function call */
inregs.h.ah = 0x44;
inregs.h.al = 0x0e;
/* Get Logical Drive Map */
drive_value = "C"; /* Set check for drive C */
inregs.h.bl = (drive_value - "A" + 1)
intdos(&inregs,&outregs);
printf("Drive %c does %sexist.",drive_value,
((outregs.x.cflag & 1) ? "not " : ""));
}
What this routine will do is test for the logical drive of C. If it
exists, then the outregs.x.cflag test will fail and the message will be
DOES EXIST. I use the function call 0x44 for interrupt 21 because it only
does a system configuration block devices, it never actually accesses any
disk. By placing your own values in the drive_value character, it will
test for different drives.
Have Fun!
****************************************************************************
* Thank You, texbell!letni!rwsys!trsvax!slimer *
* Bill "I do windows." - ComputerWorld *
* George W. Pogue, 1300 Two Tandy, Fort Worth, TX. 76102 (817) 390-2871 *
****************************************************************************
wagnere@bladder.UUCP (Eric Wagner) (09/09/89)
In article <342@castle.ed.ac.uk>, erck12@castle.ed.ac.uk (Gnome) writes: > > Here is one for the hackers among you! I want to poll a given (i.e. > not necasarily physical) drive, given a drive letter supplied by the user. I > want to find out if it is present, and functional without generating any DOS > "retry, abort or ..." or "insert diskette for drive X" type messages. I am > working in MSC 5.1. How would I go about it? Also, how would one go about detecting when the drive door has been closed, like FASTBAK does? -- ----------------------------- Eric Wagner (wagnere@gtephx) AGCS (formerly GTE), Phoenix (602) 582-7150 UUCP: {ncar!noao!asuvax | uunet!hrc | att}!gtephx!wagnere
mike@relgyro.stanford.edu (Mike Macgirvin) (09/13/89)
In article <45855611.15768@bladder.UUCP> wagnere@bladder.UUCP (Eric Wagner) writes: >In article <342@castle.ed.ac.uk>, erck12@castle.ed.ac.uk (Gnome) writes: >> Here is one for the hackers among you! I want to poll a given (i.e. >> not necasarily physical) drive, given a drive letter supplied by the user. I >> want to find out if it is present, and functional without generating any DOS >> "retry, abort or ..." or "insert diskette for drive X" type messages. I am >> working in MSC 5.1. How would I go about it? > >Also, how would one go about detecting when the drive door has been >closed, like FASTBAK does? > Take a look at the _harderr() and _hardresume() functions. They will do what you ask. The only problem I had with them was figuring out the specific error from the error codes. I ended up running a dummy program, and created the hard errors that *I* wanted to catch, while printing out the error numbers. Any other errors should be left to DOS. (i.e. you probably don't want to leave your prgram running with a major keyboard failure...). /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + I only speak for myself, and MY brain has been turned to MUSH! + + Mike Macgirvin + + - Systems Administrator Stanford Relativity Gyroscope Experiment (GP-B) + + - Internet: mike@relgyro.stanford.edu (36.64.0.50) + + - Bitnet: mike%relgyro.stanford.edu@stanford + + - Uucp: uunet!relgyro.stanford.edu!mike + + "'Scuse me, while I kiss the sky" - Robert James Marshall (Jimi) Hendrix + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
d88-eli@nada.kth.se (Erik Liljencrantz) (09/15/89)
In article <331@helens.Stanford.EDU> mike@relgyro.STANFORD.EDU (Mike Macgirvin) writes: >In article <45855611.15768@bladder.UUCP> wagnere@bladder.UUCP (Eric Wagner) writes: >>In article <342@castle.ed.ac.uk>, erck12@castle.ed.ac.uk (Gnome) writes: >>> Questions about determining valid drive letters and open drive doors. > Suggestion to use _harderr() and _hardresume() in MSC 5.1 To determine if a drive letter is valid, use the MSDOS INT 21 (AH=xx) function select drive and then use INT 21 (AH=yy) return current drive and check if they are equal (Sorry about the xx and yy, but I don't have the manual at hand...). I don't know about the open drive door, but MSDOS doesn't know either... --- Erik Liljencrantz | "No silly qoutes!!" d88-eli@nada.kth.se | Embraquel D. Tuta