⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iunknown.cpp

📁 英文版的 想要的话可以下载了 为大家服务
💻 CPP
字号:
/*
 * IUNKNOWN.CPP
 *
 * Template implementation of a delegating IUnknown.
 *
 * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
 *
 * Kraig Brockschmidt, Microsoft
 * Internet  :  kraigb@microsoft.com
 * Compuserve:  >INTERNET:kraigb@microsoft.com
 */


#include "iunknown.h"


/*
 * CImpIUnknown::CImpIUnknown
 * CImpIUnknown::~CImpIUnknown
 *
 * Constructor Parameters:
 *  pObj            LPVOID of the object containing us.
 *  pUnkOuter       LPUNKNOWN to which we blindly delegate
 *                  all IUnknown calls.
 */

CImpIUnknown::CImpIUnknown(LPVOID pObj, LPUNKNOWN pUnkOuter)
    {
    m_cRef=0;
    m_pObj=pObj;

    /*
     * We don't need to AddRef pUnkOuter since it defines
     * our lifetime.
     */
    m_pUnkOuter=pUnkOuter;
    return;
    }


CImpIUnknown::~CImpIUnknown(void)
    {
    return;
    }




/*
 * CImpIUnknown::QueryInterface
 *
 * Purpose:
 *  Delegate to whoever is providing IUnknown implementations
 *  for this interface.  May be our containing object, may be
 *  a controlling unknown.  We don't care.
 *
 * Parameters:
 *  riid            REFIID being asked for.
 *  ppv             LPVOID * in which to return the interface.
 *
 * Return Value:
 *  HRESULT         NOERROR if successful, otherwise contains
 *                  E_NOINTERFACE.
 */

STDMETHODIMP CImpIUnknown::QueryInterface(REFIID riid
    , LPVOID *ppv)
    {
    return m_pUnkOuter->QueryInterface(riid, ppv);
    }





/*
 * CImpIUnknown::AddRef
 *
 * Purpose:
 *  Increments the interface reference count (for debugging) and
 *  delegates to whoever is controlling this interface.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  ULONG           New reference count of the object.
 */

STDMETHODIMP_(ULONG) CImpIUnknown::AddRef(void)
    {
    ++m_cRef;
    return m_pUnkOuter->AddRef();
    }






/*
 * CImpIUnknown::Release
 *
 * Purpose:
 *  Decrements the interface reference count (for debugging) and
 *  delegates to whoever is controlling this interface.
 *
 * Parameters:
 *  None
 *
 * Return Value:
 *  ULONG           Current reference count after decrement.  If
 *                  this returns zero then the interface is no
 *                  longer valid because the object is dead.
 */

STDMETHODIMP_(ULONG) CImpIUnknown::Release(void)
    {
    --m_cRef;
    return m_pUnkOuter->Release();
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -