I want to get the name or label of drive.
I use this function :
function GetVolumeLabel(DriveChar: Char): string;
var
NotUsed: DWORD;
VolumeFlags: DWORD;
VolumeInfo: array[0..MAX_PATH] of Char;
VolumeSerialNumber: DWORD;
Buf: array [0..MAX_PATH] of Char;
begin
GetVolumeInformation(PChar(DriveChar + ':\'),
Buf, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed,
VolumeFlags, nil, 0);
SetString(Result, Buf, StrLen(Buf)); { Set return result }
Result:=AnsiUpperCase(Result)
end;
For example, here're my drives in Windows Explorer :
Local Disk (C:)
Data (D:)
DVD RW Drive (E:)
The output of the code :
C:
D: DATA
E:
The labels of C and E are empty. What winapi/function should I use to display the label of unnamed drive (C and E)?