getdisk, setdisk

De RAD Studio
Aller à : navigation, rechercher

Remonter à dir.h - Index

Header File



Directory Control Routines


int getdisk(void);

int setdisk(int drive);


Gets or sets the current drive number.

getdisk gets the current drive number. It returns an integer: 0 for A, 1 for B, 2 for C, and so on.

setdisk sets the current drive to the one associated with drive: 0 for A, 1 for B, 2 for C, and so on.

The setdisk function changes the current drive of the parent process.

Return Value

getdisk returns the current drive number. setdisk returns the total number of drives available. If the drive parameter for setdisk is an invalid drive number, the returned value is 0.


#include <stdio.h>
#include <dir.h>
int main(void)
  int disk, maxdrives = setdisk(2);
  disk = getdisk() + 'A';
  printf("\nThe number of logical drives is:%d\n", maxdrives);
  printf("The current drive is: %c\n", disk);
  return 0;