unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DiskInfo, StdCtrls;

type
  TForm1 = class(TForm)
    Label8: TLabel;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Serial: TLabel;
    Volume: TLabel;
    System: TLabel;
    Label5: TLabel;
    DriveType: TLabel;
    Label6: TLabel;
    DiskSize: TLabel;
    Label7: TLabel;
    DiskFree: TLabel;
    Label1: TLabel;
    GroupBox1: TGroupBox;
    ComboBox1: TComboBox;
    DiskInfo: TDiskInfo;
    procedure ComboBox1Change(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  DiskInfo.Disk := ComboBox1.Items[ComboBox1.ItemIndex][1];

// Error
  if DiskInfo.SerialNumber = 0 then
   Application.MessageBox('Error reading disk parameters.', 'Error', mb_Ok or mb_IconStop);

  Serial.Caption := DiskInfo.SerialNumberStr;
  Volume.Caption := DiskInfo.VolumeLabel;
  System.Caption := DiskInfo.FileSystem;
  DiskSize.Caption := DiskInfo.DiskSizeStr;
  DiskFree.Caption := DiskInfo.DiskFreeStr;

  case DiskInfo.DriveType of
     dtFloppy: DriveType.Caption := 'Floppy';
      dtFixed: DriveType.Caption := 'Fixed';
    dtNetwork: DriveType.Caption := 'Network';
      dtCDROM: DriveType.Caption := 'CD-ROM';
        dtRAM: DriveType.Caption := 'RAM';
   end;
end;

procedure TForm1.FormActivate(Sender: TObject);
var
  DriveNum: Integer;
  DriveBits: set of 0..25;
  DriveType: TDriveType;
  St: String;
begin
  Integer(DriveBits) := GetLogicalDrives;
  for DriveNum := 0 to 25 do
   begin
    if not (DriveNum in DriveBits) then Continue;
    
// optional    
    DriveType := TDriveType(GetDriveType(PChar(Char(DriveNum + 65) + ':\')));
    case DriveType of
       dtFloppy: St := ' - [Floppy]';
        dtFixed: St := ' - [Fixed]';
      dtNetwork: St := ' - [Network]';
        dtCDROM: St := ' - [CD-ROM]';
          dtRAM: St := ' - [RAM]';
     end;

    ComboBox1.Items.Add(Char(DriveNum + 65) + St);
   end;
end;

end.
