System Delphi

Title: stop Windows from displaying critical error messages?
var
wOldErrorMode: Word;
begin
wOldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
try
//Error code here
finally
SetErrorMode(wOldErrorMode);
end;
end;