We run a DataSnap Delphi 2009 application on Windows 2003 Server. DataSnap Client and Server are on the same computer, using DCOM over Borland Socketserver. The client runs a background batch job.
Sometimes, we discover that the client can not connect to the server application and displays a message dialog on the server desktop indicating for example "Could not connect to server. Network path could not be found." or "Objectexporter not found."
Our Delphi client code never uses a message dialog to show errors or exceptions, instead we use try ... except .. finally ... end and logging to handle connect errors, so I guess the dialog is created by a DataSnap method. Is there a way to suppress this modal dialog box?
Update: all exceptions are handled in lower level routines, the main loop takes care of disconnecting and reconnecting when an exception is raised (handled or unhandled):
while True do
begin
Connect;
while True do
begin
try
DoMyWork;
except
Break;
end;
end;
Disconnect;
end;
solution 1) maybe an global hook over the application.onexception can handle the problem
http://www.chami.com/tips/delphi/011497D.html
solution 2)
use EurekaLog or MadExcept in order to find out from where the application raise that error, and handle the error.
solution 3)
a global hook over the application message dialogs, a hook example is bellow
you query all the application's messages, and when you catch that window then you process the message not the application. because i don't have now the time I don't know exactly which is the wmessage raised by messagedlg.
hope that helped.
best regards,
来源:https://stackoverflow.com/questions/3316692/how-can-i-supress-delphi-datasnap-error-message-dialogs