Mega Code Archive

 
Categories / Delphi / API
 

Getting a list of the available drives on a system

Question: Is there a fast way to get a list of the available drives on a system? Answer: The following example demonstrates getting a list of the available logical drives available on the system. procedure TForm1.Button1Click(Sender: TObject); var ld : DWORD; i : integer; begin ld := GetLogicalDrives; for i := 0 to 25 do begin if (ld and (1 shl i)) <> 0 then Memo1.Lines.Add(Char(Ord('A') + i) + ':\'); end; end;