1 2 unit Unit1; 3 4 interface 5 6 uses 7 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 8 Dialogs, StdCtrls; 9 10 type 11 TForm1 = class(TForm) 12 Button1: TButton; 13 procedure Button1Click(Sender: TObject); 14 private 15 { Private declarations } 16 public 17 { Public declarations } 18 end; 19 20 var 21 Form1: TForm1; 22 23 implementation 24 25 {$R *.dfm} 26 27 28 function CheckFloppy(driveletter: Char) : string; 29 var 30 mask: string[6]; 31 sRec: TSearchRec; 32 oldMode: Cardinal; 33 retcode: Integer; 34 begin 35 oldMode:= SetErrorMode(SEM_FAILCRITICALERRORS); 36 mask:= '?:\*.*'; 37 mask[1] := driveletter; 38 {$I-} 39 retcode := FindFirst (mask, faAnyfile, SRec); 40 FindClose(SRec); 41 {$I+} 42 case retcode of 43 0: Result := 'Disk with files found.'; 44 -18: Result := 'Empty Disk Found.'; 45 -21, -3: Result := 'DOS Error Drive Not Ready'; 46 47 else 48 Result := 'NO Disk in Drive'; { unformatted disk in drive } 49 end; 50 SetErrorMode(oldMode); 51 end; { DriveState } 52 53 procedure TForm1.Button1Click(Sender: TObject); 54 begin 55 ShowMessage(CheckFloppy('A')); 56 end; 57 58 end.