Hello,
I work for some time with COM and especially with ATL template classes, but I am not an expert so please be patient with me if this is a stupid question.
I now want to create a singleton COM Object which is hostet by a windows service. I decide to use a service cause it can run under system account.
Here are my steps in detail:
1. Create an ATL project("ATLService.exe") as a service(.exe) with VS2010 SP1.
2. Add an ATL Simple Object to the project, also add the ProgId"ATLService.ComObject" to the wizzard.
3. Change the *.rgs of the ATLService to get the entry in dcomcnfg like:
NoRemove AppID
{
'%APPID%' = s 'ATLService'
'ATLService.EXE'
{
val AppID = s '%APPID%'
}
}
4.Compile the project an register with /Service, so the ComObject can be found in the registry and the ATLServcie can be found in services.msc and in dcomcnfg
5. Add the user to the Launch, Access und Activation permission of the service in dcomcnfg settings.
6. Identity of the service is system account
7. start service in service.msc
8. Start a client to create an instance of ATLService.ComObject.1 like this:
wchar_t wszProg[] = {L"ATLService.ComObject.1"};
CLSID clsid;
HRESULT hr = CLSIDFromProgID(wszProg,&clsid);
CComPtr<IUnknown> pUnk;
hr = ::CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,
IID_IUnknown,(void**)&pUnk);
For CoCreateInstance i got the 0x80080005 server execution failed message. It is really frustrating. If I change the register from /service to /regserver it works well. What could be the reason?