Tuesday, March 1, 2011

How to stop Windows from displaying critical error messages

When performing certain functions it is necessary for your program to take full control over error messages. For example, if your program wants to "quietly" check if a floppy drive has a floppy disk in it, you may not want Windows to display a "critical error" if in fact the floppy drive is empty.
You can control which error messages Windows display by using the "SetErrorMode()" Win API function as follows:

var
wOldErrorMode : Word;
begin
{
tell windows to ignore critical
errors and save current error mode
}

wOldErrorMode :=
SetErrorMode(
SEM_FAILCRITICALERRORS );
try
{
code that might generate a
critical error goes here...
}

finally
{
go back to previous error mode
}

SetErrorMode( wOldErrorMode );
end;
end;
 
Source : http://www.chami.com/tips/delphi/011297D.html 

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum