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

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  DRVS.C - public domain by David Gersic, DeKalb, Il 1993
  5. **
  6. **  Routine checks how many valid disk drives are available on machine,
  7. **  both physical and logical drives.
  8. **
  9. **  Includes drive letters assigned with DOS SUBST command and network
  10. **  drives for Novell Netware (and probably other networks).
  11. **
  12. **  Compiled Under MSC 6 LARGE memory Model
  13. **  Should be compatible with other DOS compilers
  14. **
  15. */
  16.  
  17. #include <stdio.h>
  18. #include <dos.h>
  19. #include <stdlib.h>
  20.  
  21. main()
  22. {
  23.       union REGS in, out;
  24.       int i;
  25.  
  26.       /* Novell's shell TSRs allow up to 32 drive 'letters' to be created */
  27.  
  28.       char drives[]={' ','a','b','c','d','e','f','g','h','i','j',
  29.                      'k','l','m','n','o','p','q','r','s','t','u',
  30.                      'v','w','x','y','z','[','\\',']','^','_','`'};
  31.  
  32.       in.x.ax=0x4409;   /* IOCTL function - Check if block device remote  */
  33.       for(i = 1; i < 32; i++)
  34.       {
  35.             in.h.bl=(unsigned char)i;     /* 1==a:, 2==b:, etc.           */
  36.             intdos(&in,&out);
  37.             if(!out.x.cflag)        /* carry flag set on error            */
  38.             {                       /* bit 15 == subst, bit 12 == 'remote'*/
  39.                   printf("drive %c: is %s\n",
  40.                         drives[i],out.x.dx & (1<<15) ? "subst" :
  41.                         out.x.dx & (1<<12) ? "network" : "local");
  42.             }
  43.       }
  44.       return(0);
  45. }
  46.