• <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 大龍 閱讀(456) 評論(0)  編輯 收藏 引用

            99久久精品国产一区二区| 欧美精品福利视频一区二区三区久久久精品 | 老男人久久青草av高清| 国产综合成人久久大片91| 国产成人精品久久一区二区三区| 亚洲精品乱码久久久久久久久久久久 | 久久99精品久久久久久久不卡 | 国产精品欧美久久久久天天影视| 99久久精品毛片免费播放| 国产高潮国产高潮久久久| 久久亚洲精品中文字幕| 精品久久无码中文字幕| www.久久热.com| 国产精品免费看久久久香蕉| 国内精品久久久久久麻豆| 久久亚洲高清综合| 久久精品人人做人人爽电影| 婷婷伊人久久大香线蕉AV| av无码久久久久久不卡网站| 伊人久久综在合线亚洲2019| 久久亚洲欧洲国产综合| 一本色道久久综合亚洲精品| 国产成人久久AV免费| 久久久WWW成人| 亚洲午夜久久久久久久久久| 国产精品无码久久综合| 久久se精品一区二区影院| 中文字幕久久精品 | 97精品伊人久久久大香线蕉| 人妻无码αv中文字幕久久琪琪布| 漂亮人妻被黑人久久精品| 丁香五月综合久久激情| 久久久久久久91精品免费观看 | 欧美久久综合性欧美| 无码8090精品久久一区| 成人妇女免费播放久久久| 国产免费久久精品丫丫| 无码人妻久久一区二区三区免费丨| 大美女久久久久久j久久| 亚洲中文字幕无码久久精品1 | 亚洲va久久久噜噜噜久久男同|