Sample Code

windows driver samples/ Native Wifi IHV Service/ C++/ ihvsampleui/ iunk.h/

//
// Copyright (C) Microsoft Corporation 2005
// IHV UI Extension sample
//

// Common macro based implementation of IUnknown
// using a interface table approach

#define IMPLEMENT_REFCOUNT()\
    ULONG m_crefCount;\
    \
    STDMETHODIMP_(ULONG) AddRef(void)\
    {\
        return InterlockedIncrement((PLONG)&m_crefCount);\
    }\
    \
    _At_(this, __drv_aliasesMem)\
    STDMETHODIMP_(ULONG) Release(void)\
    {\
        ULONG res = InterlockedDecrement((PLONG)&m_crefCount);\
        if (res == 0)\
        {\
           delete this;\
        }\
        return res;\
    }

#define BEGIN_INTERFACE_TABLE()\
    IMPLEMENT_REFCOUNT()\
    STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject)\
    {\
        if (riid == IID_IUnknown)\
        {\
            *ppvObject = reinterpret_cast<IUnknown*>(this);\
        }

#define IMPLEMENTS_INTERFACE(Itf)\
        else if (riid == IID_ ## Itf)\
        {\
            *ppvObject = static_cast<Itf*>(this);\
        }

#define END_INTERFACE_TABLE()\
        else \
        {\
           *ppvObject = NULL;\
            return E_NOINTERFACE;\
        }\
        \
        reinterpret_cast<IUnknown *>(*ppvObject)->AddRef();\
        \
        return S_OK;\
    }

Our Services

  • What our customers say about us?

© 2011-2025 All Rights Reserved. Joya Systems. 4425 South Mopac Building II Suite 101 Austin, TX 78735 Tel: 800-DEV-KERNEL

Privacy Policy. Terms of use. Valid XHTML & CSS