home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_C
/
SNPD9404.ZIP
/
DRIVSRCH.C
< prev
next >
Wrap
Text File
|
1994-04-03
|
2KB
|
70 lines
.I 2 2
**
** Modified by Bob Stout
.I 8 12
** Includes drive letters assigned with DOS SUBST command
**
** Networked drives are left as an exercise as I don't have access
** to them to check.
**
** The routine uses undocumented DOS interrupt 32H.
**
** Compatible with MSC 5 and 6, ZTC++, BC++, other DOS compilers
**
** DS:BX contains the address of the Disk Parameter Block (DPB) for a
** requested drive. If the drive letter at offset 0 of the DPB doesn't
** match the requested drive, then the drive has been SUBST'ed.
.D 9 15
.I 28 7
#if !defined(MK_FP)
#define MK_FP(seg,off) ((void far *)(((long)(seg) << 16)|(unsigned)(off)))
#endif
#ifdef __TURBOC__
#define _far far
#endif
.D 29 1
.I 34 5
int drivestatus[26];
unsigned char _far *DPB;
union REGS regs;
struct SREGS sregs;
.D 35 5
.I 42 6
/*
** if removeable media drive ie. floppy drive A: has a latch door
** open you will get "Abort Retry" panic message
*/
for (i = 0; i < 26; i++)
.D 43 8
.I 52 26
regs.h.dl = (unsigned char)(i + 1);
segread(&sregs);
regs.h.ah=0x32; /* DOS interrupt 32H */
/* was undocumented for DOS release 3.2 */
intdosx(®s,®s, &sregs);
result=regs.h.al;
DPB = MK_FP(sregs.ds, regs.x.bx);
/*
** result =0 then valid drive
** =255 or ff hex then invalid or non-existent drive
*/
if (0 == result && *DPB != (unsigned char)i)
drivestatus[i] = 1;
else drivestatus[i]=result;
}
for (i = 0; i < 26; i = i + 2)
{
printf("drive %c: status code =%3d drive %c: status code =%3d\n",
'A' + i,drivestatus[i],'B' + i,drivestatus[i+1]);
.D 53 21