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

  1. /* LASTDRV2.C -- uses only documented DOS */
  2.  
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. main()
  7. {
  8.     unsigned lastdrv;
  9.  
  10. #ifdef __TURBOC__
  11.     asm mov ah, 19h         /* C-style comments only */
  12.     asm int 21h
  13.     asm mov dl, al
  14.     asm mov ah, 0x0e        /* C-style hex */
  15.     asm int 21h             /* assembly-style hex */
  16.     asm xor ah, ah
  17.     asm mov lastdrv, ax     /* refer to C variables */
  18. #elif (defined(_MSC_VER) && (_MSC_VER >= 600)) || defined(_QC)
  19.     _asm {
  20.         mov ah, 19h         ; can include assembly-style comments
  21.         int 21h             /* and C-style as well */
  22.         mov dl, al          // and this style as well
  23.         mov ah, 0x0E        ; can include C-style hex numbers
  24.         int 21h             ; or assembly-style hex numbers
  25.         xor ah, ah
  26.         mov lastdrv, ax     ; can refer to C variables in _asm
  27.         }
  28. #else
  29. #error Requires inline assembler
  30. #endif
  31.  
  32.     fputs("LASTDRIVE=", stdout);
  33.     putchar('A' - 1 + lastdrv);
  34.     putchar('\n');
  35.     return lastdrv;
  36. }
  37.