RAD Studio
ContentsIndex
PreviousUpNext
getdisk, setdisk

Header File 

dir.h  

Category 

Directory Control Routines 

Prototype 

int getdisk(void); 

int setdisk(int drive); 

Description 

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. 

Example  

#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;
 }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!