Component Object Model and ATL implementation addendum

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.