![]() |
|
|
|
|
#1
|
|||
|
|||
|
Возник спор с товарищем, возможно как и многие решил показаться умнее. Код следующего содержания, приведенный мною, он назвал, цитирую:
Цитата:
Я предложил вот так: Код:
var
DType: Byte;
Drive: Char;
begin
for Drive := 'a' to 'z' do
begin
DType := GetDriveType(PChar(Drive+':\'));
case DType of
3: FindFile(Drive + ':\');
end;
end;
CreateForm; //Вот это действия показывает формы
end; |
|
#2
|
||||
|
||||
|
|
|
#3
|
||||
|
||||
|
исходник компонента TDriveComboBox:
Код:
procedure TDriveComboBox.BuildList;
var
DriveNum: Integer;
DriveChar: Char;
DriveType: TDriveType;
DriveBits: set of 0..25;
procedure AddDrive(const VolName: string; Obj: TObject);
begin
Items.AddObject(Format('%s: %s',[DriveChar, VolName]), Obj);
end;
begin
{ fill list }
Clear;
Integer(DriveBits) := GetLogicalDrives;
for DriveNum := 0 to 25 do
begin
if not (DriveNum in DriveBits) then Continue;
DriveChar := Char(DriveNum + Ord('a'));
DriveType := TDriveType(GetDriveType(PChar(DriveChar + ':\')));
if TextCase = tcUpperCase then
DriveChar := Upcase(DriveChar);
case DriveType of
dtFloppy: Items.AddObject(DriveChar + ':', FloppyBMP);
dtFixed: AddDrive(VolumeID(DriveChar), FixedBMP);
dtNetwork: AddDrive(NetworkVolume(DriveChar), NetworkBMP);
dtCDROM: AddDrive(VolumeID(DriveChar), CDROMBMP);
dtRAM: AddDrive(VolumeID(DriveChar), RAMBMP);
end;
end;
end; |