Generic classes templates with COM Interfaces RRS feed

  • Question

  • Hi 

    this is my generic class with templates when I try to query using QueryInterface 

    here the spDispatch is always NULL this doesn't work in VS2017 with windows server 2016 please help in resolving this 

    though this works fine with VS2015 and windows server 2012 

     CComPtr<IDispatch> spDispatch;
    m_obj->QueryInterface (IID_IDispatch, (void**)&spDispatch); // here spDispatch is always NULL


    template<class T0, class... T>
    struct GetFirstParameterPackType { typedef T0 Value; };

    template<class... Interfaces>
    class ScriptHostObjectBase : public Interfaces..., public CComObjectRootEx<CComMultiThreadModelNoCS>
        typedef ScriptHostObjectBase<Interfaces...> Self;
        typedef std::function<IDispatch* (Self*)> InterfaceCastFunc;
        typedef typename GetFirstParameterPackType<Interfaces...>::Value FirstInterface;
        static const int InterfaceCount = sizeof...(Interfaces);
        static const GUID InterfaceGuids[InterfaceCount];
        static const InterfaceCastFunc CastFuncs[InterfaceCount];
        static ITypeInfo* TypeInfoCache[InterfaceCount];

        struct Entry
            UINT interfaceIdx;
            DISPID dispid;

        const DISPID BaseVirtualDispID = 0x40000000;
        const DISPID MaxVirtualDispID = 0x50000000;
        std::vector<Entry> m_vecDispIDs;

            COM_INTERFACE_ENTRY2(IDispatch, FirstInterface)

    Tuesday, February 26, 2019 10:39 AM

All replies

  • Arathij,

    Sorry but you have posted to a forum that deals exclusively with questions/issues about customizing and programming Microsoft Project, a project management application. I suggest you re-post to the following forum:


    Tuesday, February 26, 2019 5:41 PM
  • thank you will do 
    Wednesday, February 27, 2019 3:08 AM