给介函数。<br>function DiskInDrive(Drive: Char): Boolean;<br>var<br> ErrorMode: word;<br>begin<br>if Drive in ['a'..'z'] then<br> Dec(Drive, $20);<br>if not (Drive in ['A'..'Z']) then<br> raise EConvertError.Create(Format('%S 不是有效的驱动器符号',[Drive]) );<br>ErrorMode := SetErrorMode(SEM_FailCriticalErrors);<br>try<br> if DiskSize(Ord(Drive) - $40) = -1 then<br> Result := False<br> else<br> Result := True;<br>finally<br> SetErrorMode(ErrorMode);<br>end;<br>end;<br><br>例子<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>if not DiskInDrive('A') then<br> showmessage('no disk in a');<br>end;<br><br>