Component Object Model and ATL implementation Addendum
Cheungmine
2007-10-11
The component object model and the ATL implementation document have been written, but a key issue is missing. There is another place where you need to modify the atlcom. h file. I will change it here. Open atlcom0.h after correction in the previous article and find the following function:
Stdmethodimp ienumonstlimpl <base, piid, T, copy, colltype >:: next
Correct it to (just change the bold area, in one sentence)
HR = copy: Copy (pelt, & * m_iter );
Change
HR = copy: Copy (pelt, * m_iter );
The complete function after the change 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: Destroy (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 questions, refer to my sample code.
Http://download.csdn.net/source/260939