A: One way of doing
that is utilizing the information in DPB, that
is the Drive Parameter Block, but that is rather complicated, so you
can find that without source code in the TSUNTH unit in
ftp://garbo.uwasa.fi/pc/ts/tspa3470.zip .
Another way is using interrupt 21H, function 36H to detect if a
drive exists starting from the first drive letter. The code is given
below. The disadvantage of this method is that it does not
distinguish between real and substituted drives.
uses Dos;
function LASTDFN : char; (* Detect last harddisk letter *)
var regs : registers;
i : byte;
begin
i := 2;
repeat
Inc(i);
FillChar (regs, SizeOf(regs), 0);
regs.ah := $36;
regs.dl := i;
MsDos(regs);
until (regs.ax = $FFFF);
lastdfn := chr(i+63);
end; (* lastdfn *)