Getting drive letter when given a number
   


I sometimes use a "for i := 1 to 26" loop to cycle through the drives and created this function to give me the drive letter of the current i value. To get the drive number for a given drive letter, see GetDriveNumber().

function GetDriveLetter(Drive: byte): char;
{ func to return the drive letter. Ex: 1 = A, 2 = B, 3 = C, etc. }
begin
  if (Drive >= 1) and (Drive <= 26) then
    Result := chr(ord('A') + Drive - 1)
  else
    Result := ' ';
end;


Blue Orb Software

[email protected]