
const
  SEM_NOGPFAULTERRORBOX = $0002;
  SEM_FAILCRITICALERRORS = $0001;
  SEM_NOOPENFILEERRORBOX = $8000;
  SEM_NOALIGNMENTFAULTEXCEPT = $0004;

procedure clSetErrorMode(m: UINT);
var
  dll: THandle;
//UINT WINAPI GetErrorMode(void);
  _SetErrorMode: function(uMode:UINT):UINT; stdcall;
begin
  dll:= LoadLibrary('kernel32.dll');
  if dll = 0 then Exit;
  pointer(_SetErrorMode):= GetProcAddress(dll, 'SetErrorMode');
  if Assigned(_SetErrorMode) then _SetErrorMode(m);
  FreeLibrary(dll);
end;


function clGetErrorMode: UINT;
var
  dll: THandle;
//UINT WINAPI GetErrorMode(void);
  _SetErrorMode: function(uMode:UINT):UINT; stdcall;
begin
  Result:=0;
  dll:= LoadLibrary('kernel32.dll');
  if dll = 0 then Exit;
  pointer(_SetErrorMode):= GetProcAddress(dll, 'SetErrorMode');
  if Assigned(_SetErrorMode) then begin
    Result:= _SetErrorMode(0);
    _SetErrorMode(Result);
  end;
  FreeLibrary(dll);
end;
