2009. szeptember 7., hétfő
How to trap the system error when a user tries to access a floppy drive with no disk in it
Problem/Question/Abstract:
How can I trap the system error that results from a user trying to access a floppy drive that has no disk in it. I want to show my own error message etc., rather than the system one.
Answer:
procedure TForm1.Button1Click(Sender: TObject);
var
ErrorMode: word;
begin
ErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
if DiskSize(1) = -1 then
ShowMessage('No disk in drive A')
else
begin
{ Your code }
end;
finally
SetErrorMode(ErrorMode);
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése