home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l440 / 2.ddi / CHAP2 / LASTDRV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-25  |  848 b   |  31 lines

  1. /*
  2. LASTDRV.C -- uses only documented DOS
  3.  
  4. Microsoft C 6.0:
  5.     cl -qc lastdrv.c
  6.  
  7. Borland Turbo C++:
  8.     tcc lastdrv
  9. */
  10.  
  11.  
  12. #include <stdio.h>
  13. #include <dos.h>
  14.  
  15. main(void)
  16. {
  17.     union REGS r;                 
  18.     unsigned lastdrv;
  19.  
  20.     r.h.ah = 0x19;               /* Get Current Disk */
  21.     int86(0x21, &r, &r);         /* call MS-DOS */
  22.     r.h.dl = r.h.al;             /* r.h.al now holds current drive */
  23.     r.h.ah = 0x0E;               /* Select Disk */
  24.     int86(0x21, &r, &r);         /* call MS-DOS */
  25.     lastdrv = r.h.al;            /* r.h.al now holds number of drives */
  26.     fputs("LASTDRIVE=", stdout); /* output string */
  27.     putchar('A' - 1 + lastdrv);  /* output drive letter */
  28.     putchar('\n');               /* output newline */
  29.     return lastdrv;              /* return drive number to MS-DOS */
  30. }
  31.