Redigera

Dela via


IDispatchImpl Class

Provides a default implementation for the IDispatch part of a dual interface.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

Syntax

template<class T,
        const IID* piid= &__uuidof(T),
        const GUID* plibid = &CAtlModule::m_libid,
        WORD wMajor = 1,
        WORD wMinor = 0,
        class tihclass = CComTypeInfoHolder>
class ATL_NO_VTABLE IDispatchImpl : public T

Parameters

T
[in] A dual interface.

piid
[in] A pointer to the IID of T.

plibid
[in] A pointer to the LIBID of the type library that contains information about the interface. By default, the server-level type library is passed.

wMajor
[in] The major version of the type library. By default, the value is 1.

wMinor
[in] The minor version of the type library. By default, the value is 0.

tihclass
[in] The class used to manage the type information for T. By default, the value is CComTypeInfoHolder.

Members

Public Constructors

Name Description
IDispatchImpl::IDispatchImpl The constructor. Calls AddRef on the protected member variable that manages the type information for the dual interface. The destructor calls Release.

Public Methods

Name Description
IDispatchImpl::GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers.
IDispatchImpl::GetTypeInfo Retrieves the type information for the dual interface.
IDispatchImpl::GetTypeInfoCount Determines whether there is type information available for the dual interface.
IDispatchImpl::Invoke Provides access to the methods and properties exposed by the dual interface.

Remarks

IDispatchImpl provides a default implementation for the IDispatch part of any dual interface on an object. A dual interface derives from IDispatch and uses only Automation-compatible types. Like a dispinterface, a dual interface supports early binding and late binding; however, a dual interface also supports vtable binding.

The following example shows a typical implementation of IDispatchImpl.

class ATL_NO_VTABLE CBeeper :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CBeeper, &CLSID_Beeper>,
   public IDispatchImpl<IBeeper, &IID_IBeeper, &LIBID_NVC_ATL_COMLib, /*wMajor =*/ 1, /*wMinor =*/ 0>

By default, the IDispatchImpl class looks up the type information for T in the registry. To implement an unregistered interface, you can use the IDispatchImpl class without accessing the registry by using a predefined version number. If you create an IDispatchImpl object that has 0xFFFF as the value for wMajor and 0xFFFF as the value for wMinor, the IDispatchImpl class retrieves the type library from the .dll file instead of the registry.

IDispatchImpl contains a static member of type CComTypeInfoHolder that manages the type information for the dual interface. If you have multiple objects that implement the same dual interface, only one instance of CComTypeInfoHolder is used.

Inheritance Hierarchy

T

IDispatchImpl

Requirements

Header: atlcom.h

IDispatchImpl::GetIDsOfNames

Maps a set of names to a corresponding set of dispatch identifiers.

STDMETHOD(GetIDsOfNames)(
    REFIID riid,
    LPOLESTR* rgszNames,
    UINT cNames,
    LCID lcid,
    DISPID* rgdispid);

Remarks

See IDispatch::GetIDsOfNames in the Windows SDK.

IDispatchImpl::GetTypeInfo

Retrieves the type information for the dual interface.

STDMETHOD(GetTypeInfo)(
    UINT itinfo,
    LCID lcid,
    ITypeInfo** pptinfo);

Remarks

See IDispatch::GetTypeInfo in the Windows SDK.

IDispatchImpl::GetTypeInfoCount

Determines whether there is type information available for the dual interface.

STDMETHOD(GetTypeInfoCount)(UINT* pctinfo);

Remarks

See IDispatch::GetTypeInfoCount in the Windows SDK.

IDispatchImpl::IDispatchImpl

The constructor. Calls AddRef on the protected member variable that manages the type information for the dual interface. The destructor calls Release.

IDispatchImpl();

IDispatchImpl::Invoke

Provides access to the methods and properties exposed by the dual interface.

STDMETHOD(Invoke)(
    DISPID dispidMember,
    REFIID riid,
    LCID lcid,
    WORD wFlags,
    DISPPARAMS* pdispparams,
    VARIANT* pvarResult,
    EXCEPINFO* pexcepinfo,
    UINT* puArgErr);

Remarks

See IDispatch::Invoke in the Windows SDK.

See also

Class Overview