SmartPascal
GetDir
Procedure
Get the default directory (drive plus path) for a specified drive System unit
 procedure GetDir ( Drive : Byte; var Directory : string ) ;
Description
The GetDir procedure stores in the passed parameter Directory string the drive plus path name of the default directory on the specified Drive.
 
Drive values :
 
= Default drive
= A: drive
= B: drive
= C: drive
= D: drive
and so on. 
Related commands
ChDir Change the working drive plus path for a specified drive
CreateDir Create a directory
GetCurrentDir Get the current directory (drive plus directory)
ForceDirectories Create a new path of directories
MkDir Make a directory
RemoveDir Remove a directory
RmDir Remove a directory
SelectDirectory Display a dialog to allow user selection of a directory
SetCurrentDir Change the current directory
 
Example code : Getting the directory for the C: drive
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  DirName : string;

begin
  GetDir(3, DirName);   // Store C: directory in the DirName variable
  ShowMessage(DirName);
end;
 
end.
Hide full unit code
   The following output is representative, and will necessarily vary
   from PC to PC:
  
   C:\Program Files\Borland\Delphi7\Projects