The Component Object model is written with the ATL implementation article, but a key problem is missing. There is also a need to modify the atlcom.h file where I put it more here. Open the atlcom0.h that was corrected by the previous article and find the following function:
Stdmethodimp Ienumonstlimpl<base, Piid, T, Copy, Colltype>::next
Corrected to (only need to change the bold place, a word only)
hr = Copy::copy (pelt, &*m_iter);
To
hr = Copy::copy (pelt, *m_iter);
The complete function after the changed is as follows:
Template <class Base, const iid* PIID, Class T, Class Copy, class colltype>
Stdmethodimp Ienumonstlimpl<base, Piid, T, Copy, Colltype>::next (ULONG Celt, t* rgelt,
ulong* pceltfetched)
{
if (rgelt = NULL | | (Celt!= 1 && pceltfetched = NULL))
return e_pointer;
if (pceltfetched!= NULL)
*pceltfetched = 0;
if (m_pcollection = NULL)
return E_FAIL;
ULONG nactual = 0;
HRESULT hr = S_OK;
t* pelt = rgelt;
while (SUCCEEDED (HR) && m_iter!= m_pcollection->end () && nactual < Celt)
{
hr = Copy::copy (pelt, &*m_iter);
hr = Copy::copy (pelt, *m_iter); Cheungmine
if (FAILED (HR))
{
while (Rgelt < pelt)
Copy::d Estroy (rgelt++);
nactual = 0;
}
Else
{
pelt++;
m_iter++;
nactual++;
}
}
if (SUCCEEDED (HR))
{
if (pceltfetched)
*pceltfetched = nactual;
if (Nactual < Celt)
hr = S_FALSE;
}
return HR;
}
If you have any further questions, please refer to my sample code.
http://download.csdn.net/source/260939