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!!
How to close all Objects in C++
Re: How to close all Objects in C++
Start with this and start adding sections until you can narrow it down:
CoInitialize(NULL);
CComPtr cameraCollection;
cameraCollection.CoCreateInstance(CLSID_NPCameraCollection);
CoUnInitialize();
CoInitialize(NULL);
CComPtr cameraCollection;
cameraCollection.CoCreateInstance(CLSID_NPCameraCollection);
CoUnInitialize();
-
- Posts: 31
- Joined: Wed Jan 09, 2008 1:25 am
Re: How to close all Objects in C++
Thanks a lot!!
It was only a problem in the order!!
I used the INPCameraCollection like a global variable in my project, but used it only in the method I use it, it works properly.
Thanks a lot.
It was only a problem in the order!!
I used the INPCameraCollection like a global variable in my project, but used it only in the method I use it, it works properly.
Thanks a lot.