home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ISNETDR.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  49 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*----------------------------------------------------------------------*/
  4. /*  determine_drive_type -- Public Domain code from Bob Dolan           */
  5. /*                                                                      */
  6. /*  INPUT:  the drive number ( 0=current, 1=A:, 2=B:, etc. )            */
  7. /*  OUTPUT: drive type ( 0=physical drive, 1=Network drive, 2=RamDisk ) */
  8. /*----------------------------------------------------------------------*/
  9.  
  10. #include <dos.h>
  11. #include "dosfiles.h"
  12.  
  13. int drive_type(int dr)
  14. {
  15.       union REGS regs;
  16.  
  17.       regs.x.ax = 0x4409;     /* IOCTL func 9 */
  18.       regs.h.bl = (unsigned char)dr;
  19.       int86(0x21, ®s, ®s);
  20.       if (!regs.x.cflag)
  21.       {
  22.             if (regs.x.dx & 0x1000)
  23.                   return 1;   /* Network drive */
  24.  
  25.             else if (regs.x.dx == 0x0800)
  26.                   return 2;   /* RAMdisk */
  27.       }
  28.  
  29.       return 0;   /* physical drive */
  30. }
  31.  
  32. #ifdef TEST
  33.  
  34. #include <stdio.h>
  35. #include <stdlib.h>
  36. #include <ctype.h>
  37.  
  38. int main(int argc, char *argv[])
  39. {
  40.       int dr = 0;
  41.  
  42.       if (1 < argc)
  43.             dr = toupper(*argv[1]) - '@';
  44.       printf ("drive_type(%d) = %d\n", dr, drive_type(dr));
  45.       return 0;
  46. }
  47.  
  48. #endif /* TEST */
  49.