IID_PPV_ARGS macro


You’ll find it in ObjBase.h:



//  IID_PPV_ARGS(ppType)


//      ppType is the variable of type IType that will be filled


//


//      RESULTS in:  IID_IType, ppvType


//      will create a compiler error if wrong level of indirection is used.


//


extern “C++”


{


    template<typename T> void** IID_PPV_ARGS_Helper(T** pp)


    {


        // make sure everyone derives from IUnknown


        static_cast<IUnknown*>(*pp);


       


        return reinterpret_cast<void**>(pp);


    }


}


 


#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType)


And it allows you to write code like this:



CoCreateInstance(CLSID_SearchFolderItemFactory,


                 NULL,


                 CLSCTX_INPROC_SERVER,


                 IID_PPV_ARGS(&pSearchFolderItemFactory));



or



pContact->QueryInterface(IID_PPV_ARGS(&pPersistInit));


or


#define DECLARE_COM_SMARTPTR(x) _COM_SMARTPTR_TYPEDEF(x, __uuidof(x));

DECLARE_COM_SMARTPTR(IShellItem)


IShellItemPtr shellItem1;


SHCreateItemFromParsingName(L“C:\\Users\\YvesDolc”, 0, IID_PPV_ARGS(&shellItem1));


 


Hapy New Year!

Comments (0)