I have a MFC Dialog-based Automation Server. This server should not be able to be run "standalone". I.e. it should only be able to be started up when invoked by a COM client.
I am looking for a clean way to quit this program when the user starts it up manually. The most promising way I have found so far is the following code in OnInitDialog():
// If there are any outstanding COM references to this app,
// then it was created as an automation object via COM.
// If not...
// If we were not started by OLE...
// Display a warning message and quit
AfxMessageBox ("This application can only be run by a COM client");
// Perform an "exit(1)" equivalent
Unfortunately, this code is also triggered when a COM client starts the app, and I can't see why this should be the case. Could someone point out a way around this, or suggest an alternative method to achieve the result?
Thanks in advance!