Hi. I'm developing a program that instantiates a COM executable. In my machine the problem doesn't occur, but in the machine of a colleague we have this problem. The source code are the same, without any modification. We are using Visual C++ 6.0 SP5, Win2K and WinXP. The code below are the code that works in one machine and in another doesn't work.
HRESULT hr;
IUnknown * pXXXXX;
IConnectionPointContainer * pCPC;
IConnectionPoint * pCPIXXXXXEvents;
// Call COM service to create an instance.
pXXXXX = NULL;
pCPIXXXXXEvents = NULL;
pCPC = NULL;
m_pIXXXXXEvents = new CIXXXXXEvents(this);
m_bComError = TRUE;
hr = CoCreateInstance(CLSID_XXXXX, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (LPVOID*)&pXXXXX);
if (FAILED(hr))
{
pXXXXX = NULL;
OutputDebugString("Failed to create XXXXX COM object");
}
hr = pXXXXX->QueryInterface(IID_IXXXXX, (LPVOID*)&m_pIXXXXX);
if (FAILED(hr))
{
m_pIXXXXX = NULL;
OutputDebugString("Couldn't QueryInterface for m_pIXXXXX");
}
//Asking ConnectionPointContainer.
hr = pXXXXX->QueryInterface(IID_IConnectionPointContainer, (LPVOID*)&pCPC);
if(FAILED(hr))
{
OutputDebugString("Couldn't QueryInterface for pCPC");
}
//looking for ConnectionPoint into this.
hr = pCPC->FindConnectionPoint(__uuidof(_IXXXXXEvents), &pCPIXXXXXEvents);
if(FAILED(hr))
{
OutputDebugString("Couldn't FindConnectionPoint for pCPIXXXXXEvents");
}
//Registering my interfaces.
hr = pCPIXXXXXEvents->Advise(m_pIXXXXXEvents, &ulAdviseSFN);
if(FAILED(hr))
{
// the error occurs here. The hr is equal -2147220990 and the I can't be advised from
// the executable to my program.:((
OutputDebugString("Couldn't Advise for m_pIXXXXXEvents");
}
Anyone has any idea of what is happening and a suggestion of how to solve it? Thanks Dennis