1. Home
  2. Computing & Technology
  3. Delphi Programming

Stop Windows from Displaying Critical Error Messages

By , About.com Guide

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;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Converting from TFileTime to TDateTime
« How to calculate the date of Easter for a given year

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. Stop Windows from Displaying Critical Error Messages

©2009 About.com, a part of The New York Times Company.

All rights reserved.