You need to execute it on the commandline, it is how the original class was designed.
Attached updated version that not raise exceptions.
Added 2 new fields to properly play with this class and easy iterate over, depends what you want choose AvailableDrives or AvailableLetters, or both as in demo.
var
HDD: THDDInfo;
i: Integer;
begin
HDD := THDDInfo.Create;
try
// display logical drive information
for i := Low(HDD.AvailableDrives) to High(HDD.AvailableDrives) do
HDDInfos(HDD, HDD.AvailableDrives[i]);
// display partition serial number
for i := Low(HDD.AvailableLetters) to High(HDD.AvailableLetters) do
begin
HDD.DriveLetter := HDD.AvailableLetters[i];
if HDD.IsInfoAvailable then
WriteLn('Serial for Letter ', HDD.AvailableLetters[i], ': ', HDD.SerialLetter)
else
WriteLn('Drive ', HDD.AvailableLetters[i], ' has no Serial number');
end;
finally
HDD.Free;
end;
ReadLn;
end.