/*
LASTDRV.C -- uses only documented DOS

Microsoft C 6.0:
    cl -qc lastdrv.c

Borland Turbo C++:
    tcc lastdrv
*/


#include <stdio.h>
#include <dos.h>

main(void)
{
    union REGS r;                 
    unsigned lastdrv;

    r.h.ah = 0x19;               /* Get Current Disk */
    int86(0x21, &r, &r);         /* call MS-DOS */
    r.h.dl = r.h.al;             /* r.h.al now holds current drive */
    r.h.ah = 0x0E;               /* Select Disk */
    int86(0x21, &r, &r);         /* call MS-DOS */
    lastdrv = r.h.al;            /* r.h.al now holds number of drives */
    fputs("LASTDRIVE=", stdout); /* output string */
    putchar('A' - 1 + lastdrv);  /* output drive letter */
    putchar('\n');               /* output newline */
    return lastdrv;              /* return drive number to MS-DOS */
}
