October 28th, 2009, 03:36 AM
CoCreateInstance and COM server
I made an existing (GUI) application a COM server.
I access this server by a simple test program using CoCreateInstance there.
This works, i.e. if the GUI application is not started it gets started, if it is already started, there will not be an additional instance of the application and the information I want gets retrieved correctly.
If I call CoCreateInstance several times in my test application, then each time it *does* create an additional instance of my COM server and this is bad.
So what could be the reason?
What throws the interface information away (although the COM server is still running)?
Has something to be done in the COM server concerning this?
As it is an first version, I did not do anything in LockServer implementation yet (IClassFactory), just return S_OK.
Remark: Of course I should reuse the pointer I get from the first CoCreateInstance, but why do several CoCreateInstance calls corrupt the SCM?
October 30th, 2009, 04:03 PM
Re: CoCreateInstance and COM server
I found the solution.
So for all interested or having a similiar problem:
When calling CoRegisterClassObject in the COM server code,
the flags have to include REGCLS_MULTIPLEUSE.
Otherwise it behaves as described by me.
Click Here to Expand Forum to Full Width