Board index » delphi » COM Automation Server Refusing to Go Away

COM Automation Server Refusing to Go Away

Folks,

I wonder if anyone has a solution to the following.

An out-of-process (separate exe) COM Automation server (local
machine) - I'll call it the Cache Server - is invoked by another
Automation Server, the App Server. Both written in Delphi.
Everything works just fine, until someone tries to shutdown
Windows. Invariably, on both W95 and W98, Windows attempts to
shutdown the Cache Server first, leading to a COM warning message
that COM objects invoked through automation are still active, and
do you want to shutdown, etc.

I need a way to cleanly but silently shutdown the whole thing,
i.e. I need a way of suppressing the COM warning message.
Ideally, Windows should interrogate the App Server first, which
would result in the App Server freeing its COM objects and
thereby releasing teh Cache Server, but there's really no telling
which app willl be sent the WM_QUERYENDSESSION message first, or
is there?

Any ideas would be appreciated.

Andrew

Andrew J. Wozniewicz
Optimax Corporation
http://www.optimax.com

 

Re:COM Automation Server Refusing to Go Away


Hello,

Something like this can get around the warning message:

uses
  ComServ;

type
  TComServerHack = class (TComServer);

procedure TForm1.WMQueryEndSessionHandler;
begin
  while ComServer.ObjectCount > 0 do
    TComServerHack (ComServer).CountObject (FALSE);
end;

You may need to trap exceptions in App Server, in case it tries to release
COM objects from Cache server that are disconnected prematurely.

have fun
--
Binh Ly
Brickhouse Data Systems, Inc
http://www.brickhouse.com

Quote
Andrew J. Wozniewicz wrote in message <7joj55$8j...@forums.borland.com>...

>Folks,

>I wonder if anyone has a solution to the following.

>An out-of-process (separate exe) COM Automation server (local
>machine) - I'll call it the Cache Server - is invoked by another
>Automation Server, the App Server. Both written in Delphi.
>Everything works just fine, until someone tries to shutdown
>Windows. Invariably, on both W95 and W98, Windows attempts to
>shutdown the Cache Server first, leading to a COM warning message
>that COM objects invoked through automation are still active, and
>do you want to shutdown, etc.

>I need a way to cleanly but silently shutdown the whole thing,
>i.e. I need a way of suppressing the COM warning message.
>Ideally, Windows should interrogate the App Server first, which
>would result in the App Server freeing its COM objects and
>thereby releasing teh Cache Server, but there's really no telling
>which app willl be sent the WM_QUERYENDSESSION message first, or
>is there?

>Any ideas would be appreciated.

>Andrew

>Andrew J. Wozniewicz
>Optimax Corporation
>http://www.optimax.com

Other Threads