procedure TForm1.List_Drives;
var
r: LongWord;
Drives: array[0..128] of char;
pDrive: PChar;
begin
SetLength(aDrives,0);
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
SetLength(aDrives, Length(aDrives)+1);
if GetDriveType(pDrive) = DRIVE_UNKNOWN then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_UNKNOWN;
end;
if GetDriveType(pDrive) = DRIVE_NO_ROOT_DIR then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_NO_ROOT_DIR;
end;
if GetDriveType(pDrive) = DRIVE_REMOVABLE then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_REMOVABLE;
end;
if GetDriveType(pDrive) = DRIVE_FIXED then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_FIXED;
end;
if GetDriveType(pDrive) = DRIVE_REMOTE then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_REMOTE;
end;
if GetDriveType(pDrive) = DRIVE_CDROM then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_CDROM;
end;
if GetDriveType(pDrive) = DRIVE_RAMDISK then
begin
aDrives[High(aDrives)].Drive := pDrive;
aDrives[High(aDrives)].Device := DRIVE_RAMDISK;
end;
Inc(pDrive, 4);
end;
SetLength(DriveBtns, Length(aDrives));
end;