home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / DOSGDRIV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.7 KB  |  62 lines

  1. /*---------------------------------------------------------------------------
  2.  * filename - dosgdriv.c
  3.  *
  4.  * function(s)
  5.  *        _dos_getdrive - gets current drive (MSC compatible)
  6.  *        _dos_setdrive - sets current drive (MSC compatible)
  7.  *--------------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1991, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <dos.h>
  19.  
  20. /*--------------------------------------------------------------------------*
  21.  
  22. Name            _dos_getdrive - gets current drive
  23.  
  24. Usage           void _dos_getdrive(unsigned *drive);
  25.  
  26. Prototype in    dos.h
  27.  
  28. Description     gets the current drive, stores it at *drive (1=A, 2=B, etc.)
  29.  
  30. Return value    None.
  31.  
  32. *---------------------------------------------------------------------------*/
  33. void _dos_getdrive(unsigned *drive)
  34. {
  35.     _AH = 0x19;
  36.     geninterrupt(0x21);
  37.     *drive = _AL + 1;   /* convert (A=0,B=1,etc.) to (A=1,B=2,etc.) */
  38. }
  39.  
  40. /*--------------------------------------------------------------------------*
  41.  
  42. Name            _dos_setdrive - sets current drive
  43.  
  44. Usage           void _dos_setdrive(unsigned drive, unsigned *ndrives);
  45.  
  46. Prototype in    dir.h
  47.  
  48. Description     sets the current drive, where drive is:
  49.                 1 = A:, 2 = B:, 3 = C:; etc.  Stores the total
  50.                 number of drives in the system at *ndrives.
  51.  
  52. Return value    none
  53.  
  54. *---------------------------------------------------------------------------*/
  55. void _dos_setdrive(unsigned drive, unsigned *ndrives)
  56. {
  57.     _DL = drive - 1;    /* convert (A=1,B=2,etc.) to (A=0,B=1,etc.) */
  58.     _AH = 0x0e;
  59.     geninterrupt(0x21);
  60.     *ndrives = _AL;
  61. }
  62.