Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I've implimented a ATL single thread apartment based project .
class ATL_NO_VTABLE CMySrv :
	public CComObjectRootEx<ccomsinglethreadmodel>,
	public CComCoClass<cmysrv,&clsid_mysrv>,
	public IMySrv

In the method, I'm creating multiple worker threads and accessing the interface pointer from one context to another with using COM Interface "IGlobalInterfaceTable"

In the main thread registered the interface
C++
void CMySrv::save()
{
    CComQIPtr<imysrv>  pMySrv(GetUnknown());
    CComPtr<iglobalinterfacetable> l_git;
    l_git.CoCreateInstance( CLSID_StdGlobalInterfaceTable );
    l_git->RegisterInterfaceInGlobal(pMySrv, __uuidof(IMySrv), &dwCookie );

    for(int i=0;i<9;i++)
        _beginthreadex( 0,0,&(CParllelThreadOperations::ThreadFunc),LPVOID(&dwCookie), 0, &dwThId);

    ////logic implemented to wait for all the child threads
}

In the worker thread I'm passing the cookie information and would get the interface
C++
CComPtr<iglobalinterfacetable> git;
CComPtr<imysrv>  pMySrv;
HRESULT hr= 0;
if(git.CoCreateInstance( CLSID_StdGlobalInterfaceTable)>=0)
hr= git->GetInterfaceFromGlobal( dwCookie, __uuidof(IMySrv), (void**)&pMySrv);

But "GetInterfaceFromGlobal" returning "0x8000ffff" error code(it is happening rarely )
Could you please help me on this.

What I have tried:

I don't have much knowledge on GIT interface and read the other articles The Mechanics of COM+ | Mechanics | InformIT[^]
Posted
Updated 8-Nov-20 9:09am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900