_dos_getdrive

Description

Gets the current disk drive using system call 0x19.

#include <dos.h>

void _dos_getdrive( unsigned *drive );

drive Current-drive return buffer  

Remarks

The _dos_getdrive routine uses system call 0x19 to obtain the current disk
drive. The current drive is returned in the word that drive points to: 1 = drive A,
2 = drive B, and so on.

Return Value

None.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

_dos_getdiskfree, _dos_setdrive, _getdrive

Example

/* DGDRIVE.C: This program prints the letter of the current drive,

* changes the default drive to A, then returns the number of disk drives.

*/

#include <stdio.h>

#include <dos.h>

void main( void )

{

unsigned olddrive, newdrive;

unsigned number_of_drives;

/* Print current default drive information */

_dos_getdrive( &olddrive );

printf( “The current drive is: %c\n”, 'A' + olddrive - 1 );

/* Set default drive to be drive A */

printf( “Changing default drive to A\n”);

_dos_setdrive( 1, &number_of_drives );

/* Get new default drive information and total number of drives */

_dos_getdrive( &newdrive );

printf( “The current drive is: %c\n”, 'A' + newdrive - 1 );

printf( “Number of logical drives: %d\n”, number_of_drives );

/* Restore default drive */

_dos_setdrive( olddrive, &number_of_drives );

}

Output

The current drive is: C

Changing default drive to A

The current drive is: A

Number of logical drives: 26