Thema: Delphi Number of disks?

Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#5

Re: Number of disks?

  Alt 23. Aug 2007, 20:03
Delphi-Quellcode:

Procedure TForm1.GetHDDcount (Sender: TObject);
var f, i: integer;
begin
  i := 0;
  repeat
    f := FileOpen('\\.\PHYSICALDRIVE' + IntToStr(i), fmOpenRead or fmShareDenyNone);
    if f = -1 then break;
// Listbox1.Items.Add('PHYSICALDRIVE'+IntToStr(i));
    inc (i);
  until false;
HDDcount1.Caption := IntToStr(i)+' HDD';
end;
// or
function GetHDDCount: integer;
var f, i: integer;
begin
  i := 0;
  repeat
    f := FileOpen('\\.\PHYSICALDRIVE' + IntToStr(i), fmOpenRead or fmShareDenyNone);
    if f = -1 then break;
    inc (i);
  until false;
  result := i;
end;
  Mit Zitat antworten Zitat