• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統(tǒng)計

            最新評論

            CComPtr Class ---- 轉(zhuǎn)自msdn

            A smart pointer class for managing COM interface pointers.

            template<
            class T
            >
            class CComPtr
            T

            A COM interface specifying the type of pointer to be stored.

            ATL uses CComPtr and CComQIPtr to manage COM interface pointers. Both are derived from CComPtrBase, and both perform automatic reference counting.

            The CComPtr and CComQIPtr classes can help eliminate memory leaks by performing automatic reference counting. The following functions both perform the same logical operations; however, note how the second version may be less error-prone by using the CComPtr class:

            Visual C++
            // Error-checking routine that performs manual lifetime management
            // of a COM IErrorInfo object
            HRESULT CheckComError_Manual()
            {
            HRESULT hr;
            CComBSTR bstrDescription;
            CComBSTR bstrSource;
            CComBSTR bstrHelpFile;
            IErrorInfo* pErrInfo = NULL; // naked COM interface pointer
            hr = ::GetErrorInfo(0, &pErrInfo);
            if(hr != S_OK)
            return hr;
            hr = pErrInfo->GetDescription(&bstrDescription);
            if(FAILED(hr))
            {
            pErrInfo->Release();   // must release interface pointer before returning
            return hr;
            }
            hr = pErrInfo->GetSource(&bstrSource);
            if(FAILED(hr))
            {
            pErrInfo->Release();   // must release interface pointer before returning
            return hr;
            }
            hr = pErrInfo->GetHelpFile(&bstrHelpFile);
            if(FAILED(hr))
            {
            pErrInfo->Release();   // must release interface pointer before returning
            return hr;
            }
            pErrInfo->Release();      // must release interface pointer before returning
            return S_OK;
            }
            
            Visual C++
            // Error-checking routine that performs automatic lifetime management
            // of a COM IErrorInfo object through a CComPtr smart pointer object
            HRESULT CheckComError_SmartPtr()
            {
            HRESULT hr;
            CComBSTR bstrDescription;
            CComBSTR bstrSource;
            CComBSTR bstrHelpFile;
            CComPtr<IErrorInfo> pErrInfo;
            hr = ::GetErrorInfo(0, &pErrInfo);
            if(hr != S_OK)
            return hr;
            hr = pErrInfo->GetDescription(&bstrDescription);
            if(FAILED(hr))
            return hr;
            hr = pErrInfo->GetSource(&bstrSource);
            if(FAILED(hr))
            return hr;
            hr = pErrInfo->GetHelpFile(&bstrHelpFile);
            if(FAILED(hr))
            return hr;
            return S_OK;
            }   // CComPtr will auto-release underlying IErrorInfo interface pointer as needed
            

            In Debug builds, link atlsd.lib for code tracing.

             Requirements

            Header: atlbase.h

            posted on 2008-09-04 00:12 大龍 閱讀(459) 評論(0)  編輯 收藏 引用

            午夜天堂av天堂久久久| 久久综合久久综合九色| 久久综合久久性久99毛片| 欧美色综合久久久久久| 亚洲欧美日韩久久精品| 久久亚洲日韩看片无码| 伊人久久大香线蕉av一区| 久久99国产精一区二区三区| 狠狠久久综合伊人不卡| 亚洲精品无码专区久久久 | 久久久久一本毛久久久| 亚洲精品乱码久久久久久按摩| 97久久精品午夜一区二区| 久久www免费人成精品香蕉| 国产精品久久久久久久久软件| 精品久久久久久成人AV| 久久精品国产精品亚洲人人| 日韩精品久久久久久久电影蜜臀| 99久久精品免费看国产| 久久精品国产亚洲AV香蕉| 久久精品www| 久久久久久国产精品无码超碰| 国产午夜精品理论片久久| 久久精品国产亚洲AV无码麻豆 | 久久精品国产亚洲AV蜜臀色欲| 久久九九亚洲精品| 久久99精品久久久久久动态图| 亚洲国产天堂久久久久久| 成人亚洲欧美久久久久| 久久99免费视频| 久久精品国产亚洲AV无码娇色| 久久人做人爽一区二区三区| 日本久久久久久久久久| 欧美性大战久久久久久| 久久综合狠狠综合久久激情 | 久久国产精品77777| 蜜臀久久99精品久久久久久小说| 无码任你躁久久久久久老妇App| 99国内精品久久久久久久| 国产A级毛片久久久精品毛片| 97久久精品午夜一区二区|