var wOldErrorMode: Word;begin wOldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS); try //Error code here finally SetErrorMode(wOldErrorMode); end;end;