Provides access to properties and methods exposed by an IDispatchEx object.

HRESULT InvokeEx(
   DISPID id,
   LCID lcid,
   WORD wFlags,
   DISPARAMS *pdp,
   VARIANT *pVarRes, 
   EXCEPINFO *pei, 
   IServiceProvider *pspCaller 
);

Parameters

id

Identifies the member. Uses GetDispID or GetNextDispID to obtain the dispatch identifier.

lcid

The locale context in which to interpret arguments. The lcid is passed to InvokeEx to allow the object to interpret its arguments specific to a locale.

wFlags

The legal values for wFlags are:

DISPATCH_PROPERTYGET | DISPATCH_METHOD | DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF | DISPATCH_CONSTRUCT

Flags describing the context of the InvokeEx call:

Value Meaning

DISPATCH_METHOD

The member is invoked as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag may be set (defined by IDispatch).

DISPATCH_PROPERTYGET

The member is retrieved as a property or data member (defined by IDispatch).

DISPATCH_PROPERTYPUT

The member is changed as a property or data member (defined by IDispatch).

DISPATCH_PROPERTYPUTREF

The member is changed by a reference assignment rather than a value assignment. This flag is valid only when the property accepts a reference to an object (defined by IDispatch).

DISPATCH_CONSTRUCT

The member is being used as a constructor. (This is a new value defined by IDispatchEx). The legal values for wFlags are:

DISPATCH_PROPERTYGET DISPATCH_METHOD DISPATCH_PROPERTYPUT DISPATCH_PROPERTYPUTREF DISPATCH_CONSTRUCT

pdp

Pointer to a structure containing an array of arguments, an array of argument DISPIDs for named arguments, and counts for the number of elements in the arrays. See the IDispatch documentation for a full description of the DISPPARAMS structure.

pVarRes

Pointer to the location where the result is to be stored or Null if the caller expects no result. This argument is ignored if DISPATCH_PROPERTYPUT or DISPATCH_PROPERTYPUTREF is specified.

pei

Pointer to a structure that contains exception information. This structure should be filled in if DISP_E_EXCEPTION is returned. Can be Null. See the IDispatch documentation for a full description of the EXCEPINFO structure.

pspCaller

Pointer to a service provider object supplied by the caller, which allows the object to obtain services from the caller. Can be Null.

IDispatchEx::InvokeEx provides all of the same features as IDispatch::Invoke and adds a few extensions:

DISPATCH_CONSTRUCT

Indicates that the item is being used as a constructor.

pspCaller

The pspCaller allows the object access to services provided by the caller. Specific services may be handled by the caller itself or delegated to callers further up the call chain. For example, if a script engine inside a browser makes an InvokeEx call to an external object, the object can follow the pspCaller chain to obtain services from the script engine or browser. (Note that the call chain is not the same as the creation chain—also known as container chain or site chain. The creation chain may be available through some other mechanism such as IObjectWithSite.)

this pointer

When DISPATCH_METHOD is set in wFlags, there may be a "named parameter" for the "this" value. The DISPID will be DISPID_THIS and it must be the first named parameter.

The unused riid parameter in IDispatch::Invoke has been removed.

The puArgArr parameter in IDispatch::Invoke has been removed.

See the IDispatch::Invoke documentation for the following examples:

"Calling a method with no arguments"

"Getting and setting properties"

"Passing parameters"

"Indexed Properties"

"Raising exceptions during Invoke"

"Returning errors"

Expand imageReturn Value

Expand imageExample

Expand imageSee Also