> How do I find the volume name of a certain drive?
Use the GetVolumeInformation function. It returns the volume name along
with other information. See the note in MSDN about using SetErrorMode if
you're trying to find information about removable media such as floppies
and CDs and want to avoid displaying an error message to the use if there
is no disk in the drive.
This is how I would try using it (untested):
function GetVolumeName(const Volume: string): string;
// in: String specifying root directory of a disk, with a trailing
// backslash
// out: Volume name of the disk in question, or empty string on error
var
VolName: PAnsiChar;
SN, CompLen, Flags: DWord;
begin
Result := '';
GetMem(VolName, 256);
try
if GetVolumeInformation(PAnsiChar(Volume), VolName, 256,
@SN, @CompLen, @Flags, nil, 0) then Result := VolName;
finally
FreeMem(VolName);
end;
end;