[TRUCO DELPHI] Enumerar las unidades de Disco.
delphi
Procedure List_Drives; const DRIVE_UNKNOWN = 0; DRIVE_NO_ROOT_DIR = 1; DRIVE_REMOVABLE = 2; DRIVE_FIXED = 3; DRIVE_REMOTE = 4; DRIVE_CDROM = 5; DRIVE_RAMDISK = 6; var r : LongWord; Drives: array[0..128] of char; pDrive: pchar; begin r := GetLogicalDriveStrings(SizeOf(Drives), Drives); if r = 0 then exit; if r > sizeof(Drives) then raise Exception.Create(SysErrorMessage(ERROR_OUTOFMEMORY)); pDrive := Drives; while pDrive^ <> #0 do begin if GetDriveType(pDrive) = DRIVE_FIXED then Form1.ComboBox1.Items.Add(pDrive); inc(pDrive, 4); end;
Saludos!