How to close all Objects in C++
Posted: Thu Jan 24, 2008 10:54 am
Hello again!
In the software i'm developing i'm not able to close it without a break. I think it is a problem of closing properly the CComObjects but I don't know how to do it. I'm using:
For the INPCameraCollection Object:
CComPtr m_spCollection;
m_hExecutionResult = CoInitialize(NULL);
m_hExecutionResult = m_spCollection.CoCreateInstance(CLSID_NPCameraCollection);
m_spCollection->Enum();
m_spCollection->get_Count(&m_CamerasInSystem);
m_spCollection->Item(c, &AuxCamera)
I don't use DispEventAdvise(m_spCollection) like in your sample because if do it, the method Enum() doesn't return OK (but all the next methods work good).
When the aplication ends, I don't close any, only with
CoUnInitialize();
The break is on the file atmcomcli.h:
public:
typedef T _PtrClass;
~CComPtrBase() throw()
{
if (p)
p->Release(); <- On this line
}
And the direction of the p is the same that the direction of the m_spCollection.
Have you got any idea?
Thanks a lot!!
In the software i'm developing i'm not able to close it without a break. I think it is a problem of closing properly the CComObjects but I don't know how to do it. I'm using:
For the INPCameraCollection Object:
CComPtr m_spCollection;
m_hExecutionResult = CoInitialize(NULL);
m_hExecutionResult = m_spCollection.CoCreateInstance(CLSID_NPCameraCollection);
m_spCollection->Enum();
m_spCollection->get_Count(&m_CamerasInSystem);
m_spCollection->Item(c, &AuxCamera)
I don't use DispEventAdvise(m_spCollection) like in your sample because if do it, the method Enum() doesn't return OK (but all the next methods work good).
When the aplication ends, I don't close any, only with
CoUnInitialize();
The break is on the file atmcomcli.h:
public:
typedef T _PtrClass;
~CComPtrBase() throw()
{
if (p)
p->Release(); <- On this line
}
And the direction of the p is the same that the direction of the m_spCollection.
Have you got any idea?
Thanks a lot!!