this slowpoke moves

Get Hard Disk Cluster Information

uses FileCtrl

//

procedure TForm1.Button1Click(Sender: TObject);
var  i: Integer; C: String;
    DType: Integer;
    DriveString: String;
begin
 ListBox1.Clear; for i:=65 to 90 do
  begin
  C := chr(i) + ':\';
  DType:=GetDriveType(PChar(C));
   case DType of
     0: DriveString := C + ' ';
     1: DriveString:= C + ' ';
     DRIVE_REMOVABLE: DriveString:= C+' REMOVABLE USB Drive.';
     DRIVE_FIXED: DriveString:= C + ' Local FIXED Drive.';
     DRIVE_REMOTE: DriveString:= C + ' REMOTE Drive.';
     DRIVE_CDROM: DriveString:= C + ' CD-ROM.';
     DRIVE_RAMDISK: DriveString := C + ' RAM Disk.';
    end;
   if not ((DType = 0) or (DType = 1))
   then ListBox1.Items.AddObject(DriveString, Pointer(i));
  end;
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var
 RootPath: String;
 SectorsPerCluster: DWord;
 BytesPerSector: DWord;
 NumFreeClusters: DWord;   // Number of free clusters
 TotalClusters: DWord;     // Total clusters
 DriveByte: Byte;          // Drive byte value
 FreeSpace: Int64;         // Free space on drive
 TotalSpace: Int64;        // Total drive space.
begin
 with ListBox1 do
  begin
    DriveByte:=Integer(Items.Objects[ItemIndex])-64;
    RootPath:=chr(Integer(Items.Objects[ItemIndex]))+':\';
    if GetDiskFreeSpace(PChar(RootPath), SectorsPerCluster,
      BytesPerSector, NumFreeClusters, TotalClusters)
    then
     begin
      Label1.Caption:=Format('%.0n', [SectorsPerCluster*1.0]);
      Label2.Caption:=Format('%.0n', [BytesPerSector*1.0]);
      Label3.Caption:=Format('%.0n', [NumFreeClusters*1.0]);
      Label4.Caption:=Format('%.0n', [TotalClusters*1.0]);
      FreeSpace:=DiskFree(DriveByte);
      TotalSpace:=DiskSize(DriveByte);
      Label5.Caption:=Format('%.0n', [FreeSpace*1.0]);
      Label6.Caption:=Format('%.0n', [TotalSpace*1.0]);
     end
    else
     begin
      Label1.Caption:='X';
      Label2.Caption:='X';
      Label3.Caption:='X';
      Label4.Caption:='X';
      Label5.Caption:='X';
      Label6.Caption:='X';
      ShowMessage('No File founded...!');
    end;
  end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate