Borland C++ reference

_dos_getdrive, _dos_setdrive

raw OCR

Gets and sets the current drive number.

Defined in header <dos.h>

Syntax

#include <dos.h>
void _dos_getdrive(unsigned  *drivep);
void _dos_setdrive(unsigned  drivep, unsigned *ndrives);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

_dos_getdrive uses DOS function 0x19 to get the current drive number.

_dos_setdrive uses DOS function OxOE to set the current drive. _dos_setdrive stores the total number of drives at the location pointed to by ndrives.

The drive numbers at the location pointed to by drivep are as follows: 1 for A, 2 for B, 3 for C, and so on.

Return value

None. Use _dos_getdrive to verify that the current drive was changed successfully.

See also

Example

#include <stdio.h>
#include <dos.h>
int main (void)
{
   unsigned disk, maxdrives;

   /* Get the current drive.  */
   _dos_getdrive(&disk) ;
   printf ("The current drive is: %c\n", disk + 'A' - 1);
/* Set current drive  to C: */
printf ("Setting current drive to C:\n");
_dos_setdrive (3, Simaxdrives) ;
printf ("The number of logical drives is: %d\n", maxdrives);
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `_clos_getdrive, _clos_setdrive` read as `_dos_getdrive, _dos_setdrive`