Prevent display of COM component Delphi MessageBox ()

We have a Delphi 2007 COM component executable from an ISAPI application. The COM component hangs in the application because it is trying to display MessageBox (). The call to MessageBox () must occur in Delphi RTL, because it is not in our user code.

The application freezes, of course, because there are no users on the server to clear MessageBox ().

How do we set up our Delphi project so that Delphi RTL does not try to display MessageBox () in an exception?

+4
source share
5 answers

I created a block for connecting CallBox / MessageDlg calls (bypassing), so I can suppress these calls in a Windows service (to avoid my dll service freezing due to some stupid code of someone else with a message call in it) . If you want, I can search for this device and send it to you.

-1
source

Write your own exception handler and attach it to the Application.OnException event. If an OnException event handler is present, the application will not use the default MessageBox default procedure. A signature is defined as:

TExceptionEvent = procedure (Sender: TObject; E: Exception) of object; 

If this is a server, you will probably want to write the exception information to the log and possibly return some error to the user.

+3
source

What does the message say? I assume this is an exception. Why don't you put the code exception handler in the COM component and register the exception differently? (For example, using the event log). And / or fix the problem that leads to the exception in the first place.

+2
source

I don’t know any direct way in Delphi, but what you can do is write a small script in AutoIT / AutoHotKey and save this script in the system tray so that it automatically closes the MessageBox.

Believe me, it is very simple.

http://www.autoitscript.com/autoit3/index.shtml

http://www.autohotkey.com/

NTN

+1
source

Can I compile the application as a console application? I'm not sure if you can do this and still have a COM object, this will prevent dialog boxes from showing. I'm sure.

Just a thought.

0
source

Source: https://habr.com/ru/post/1285671/


All Articles