Einzelnen Beitrag anzeigen

zeras

Registriert seit: 11. Mär 2007
Ort: Saalkreis
1.643 Beiträge
 
Delphi 12 Athens
 
#2

Re: DriveComboBox Entscheidungshilfe

  Alt 30. Aug 2009, 21:08
Ich habs so gelöst. Bei mir läuft das ohne Probleme.

Delphi-Quellcode:
procedure TfSelectDrive.FormShow(Sender: TObject);
var
  dr : String;
  Idx : Integer;

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
  inherited;

  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_REMOVABLE then
      CBDrivesRemovable.Items.Add(pDrive);
    Inc(pDrive, 4);
  end;

  IDx:=CBDrivesRemovable.Items.IndexOf(Drive);
  if Idx <>-1 then begin
    try
      CBDrivesRemovable.ItemIndex:=Idx;

    except

    end;
  end;
end;
Matthias
  Mit Zitat antworten Zitat