• <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>

            大龍的博客

            常用鏈接

            統計

            最新評論

            CComPtr Class ---- 轉自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 大龍 閱讀(464) 評論(0)  編輯 收藏 引用

            久久99国产精一区二区三区| jizzjizz国产精品久久| 婷婷国产天堂久久综合五月| 久久久久亚洲?V成人无码| 国产免费久久精品99re丫y| 久久久无码精品亚洲日韩蜜臀浪潮| 国产V亚洲V天堂无码久久久| 久久久久黑人强伦姧人妻| 欧美黑人激情性久久| 久久久久综合中文字幕| 久久久久人妻一区精品性色av | 久久免费视频1| 国产成人精品久久二区二区| 国产精品乱码久久久久久软件| 国产精品久久久久影院嫩草| 久久精品国产免费观看| 久久人人爽人人爽人人片AV麻豆 | 精品久久人人做人人爽综合| 午夜不卡久久精品无码免费| 日韩久久无码免费毛片软件 | 国产精品久久久久久| 一本色综合网久久| 欧美国产精品久久高清| 伊人丁香狠狠色综合久久| 97久久精品无码一区二区天美 | 久久久久久久久久久| 亚洲а∨天堂久久精品| 国产激情久久久久影院老熟女免费| 色欲久久久天天天综合网精品| 日本WV一本一道久久香蕉| 久久久久婷婷| 亚洲欧美成人久久综合中文网| 伊人久久免费视频| 精品午夜久久福利大片| jizzjizz国产精品久久| 久久亚洲私人国产精品| 久久精品国产亚洲av麻豆小说| 国产成人精品综合久久久| 亚洲国产精品高清久久久| 少妇久久久久久久久久| 久久永久免费人妻精品下载|