请问应该如何避免软驱无盘错误?(20分)

  • 主题发起人 主题发起人 Ming618
  • 开始时间 开始时间
M

Ming618

Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是DriverList控件,在它的下拉列表中选择A后,如果A驱无盘就会出错,请问应该如何避免
 
function DiskInDrive(Drive: Char): Boolean;
var ErrorMode: word;
begin
{ make it upper case }
if Drive in ['a'..'z'] then Dec(Drive, $20);
{ make sure it's a letter }
if not (Drive in ['A'..'Z']) then
raise EConvertError.Create('Not a valid drive ID');
{ turn off critical errors }
ErrorMode := SetErrorMode(SEM_FailCriticalErrors);
try
{ drive 1 = a, 2 = b, 3 = c, etc. }
if DiskSize(Ord(Drive) - $40) = -1 then
Result := False

else
Result := True;
finally
{ restore old error mode }
SetErrorMode(ErrorMode);
end;
end;
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
777
DelphiTeacher的专栏
D
D
回复
0
查看
633
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部