Question

We have an application that uses several out of process COM objects for various tasks. If the user tells Windows to shut down while our application is running, then it sends all applications (top level windows) a shutdown notification, but the OoP COM objects can shut down before the parent is notified and gets chance to shut down cleanly, causing various errors in different components.

This is made worse as one of the OoP objects was created to host an unstable 3rd party object so it's automatically restarted when it crashes which now fails to restart as Windows is shuttting down.

While we can handle the errors on the parent processes, Is there a way for the ActiveX hosts to tell Windows "I'm not shutting down just yet, but will do in due course", or even better, make Windows not notify them in the first place?

Both the parent processes, the OoP objects and their hosts are in a mixture of C++ and VB6.

Was it helpful?

Solution

Several ways to do this. Your OOP server could just ignore the shutdown request, relying on the client shutting down and remove all reference counts. You probably do want to set a flag so that you'll know to immediately shutdown when the last object is released, a server normally keeps running for a while.

Or you could call SetProcessShutdownParameters() in the OOP server. Pass a level you got from GetProcessShutdownParameters() minus 1 so that the client always gets the shutdown notification before the server. Also works with OOP servers that don't have a hidden toplevel window to get the Windows message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top