Home   Index   About
Ultimate Pack


Custom Search
DispInvoke

_this, ptinfo, dispidMember, wFlags, pparams, pvarResult, pexcepinfo, puArgErr)
void FAR*
_this
ITypeInfo FAR* ptinfo
DISPID dispidMember
unsigned short wFlags
DISPPARAMS FAR* pparams
VARIANT FAR* pvarResult
EXCEPINFO pexcepinfo
unsigned int FAR* puArgErr

Automatically calls member functions on an interface, given type information for the interface. You can describe an interface with type information and implement IDispatch::Invoke for the interface using this single call.

Parameters

_this

Pointer to an implementation of the IDispatch interface described by ptinfo.

ptinfo

Pointer to the type information describing the interface.

dispidMember

Identifies the member. Use GetIDsOfNames or the object's documentation to obtain the dispatch ID.

wFlags

Flags describing the context of the Invoke call, as follows:

Value
Description
DISPATCH_METHOD
The member is being invoked as a method. If a property has the same name, both
this and the DISPATCH_PROPERTYGET
flag may be set.
DISPATCH_PROPERTYGET
The member is being retrieved as a
property or data member.
DISPATCH_PROPERTYPUT
The member is being changed as a
property or data member.
DISPATCH_PROPERTYPUTREF
The member is being changed via a reference assignment, rather than a
value assignment. This flag is valid
only when the property accepts a
reference to an object.

pparams

Pointer to a structure containing an array of arguments, an array of argument dispatch IDs for named arguments, and counts for number of elements in the arrays.

pvarResult

Pointer to 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.

pexcepinfo

Pointer to a structure containing exception information. This structure should be filled in if DISP_E_EXCEPTION is returned.

puArgErr

The index within rgvarg of the first argument that has an error. Arguments are stored in pdispparams->rgvarg in reverse order, so the first argument is the one with the highest index in the array. This parameter is returned only when the resulting SCODE is DISP_E_TYPEMISMATCH or DISP_E_PARAMNOTFOUND.

Return Value

The SCODE obtained from the returned HRESULT is one of the following:

SCODE
Meaning
S_OK
Success.
DISP_E_BADPARAMCOUNT
The number of elements provided in DISPPARAMS is different from the number of arguments accepted by the method or property.
DISP_E_BADVARTYPE
One of the arguments in DISPPARAMS is not a valid variant type.
DISP_E_EXCEPTION
The application needs to raise an exception. In this case, the structure passed in pexcepinfo should be filled in.
DISP_E_MEMBERNOTFOUND
The requested member does not exist.
DISP_E_NONAMEDARGS
This implementation of IDispatch does not support named arguments.
DISP_E_OVERFLOW
One of the arguments in DISPPARAMS could not be coerced to the specified type.
DISP_E_PARAMNOTFOUND
One of the parameter IDs does not correspond to a parameter on the method. In this case puArgErr is set to the first argument that contains the error.
DISP_E_PARAMNOTOPTIONAL
A required parameter was omitted.
DISP_E_TYPEMISMATCH
One or more of the arguments could not be coerced. The index within rgvarg of the first parameter with the incorrect type is returned in puArgErr.
E_INVALIDARG
One of the arguments is invalid.
E_OUTOFMEMORY
Insufficient memory to complete operation.
Other returns
Any of the ITypeInfo::Invoke errors may also be returned.

Comments

The parameter _this is a pointer to an implementation of the interface being deferred to. DispInvoke builds a stack frame, coerces parameters using standard coercion rules, pushes them on the stack, and calls the correct member function in the virtual function table (VTBL).

Example

The following code from the Lines sample file LINES.CPP implements IDispatch::Invoke using DispInvoke. This function uses m_bRaiseException to signal that an error occurred during the DispInvoke call.

STDMETHODIMP

CLines::Invoke(

DISPID dispidMember,

REFIID riid,

LCID lcid,

WORD wFlags,

DISPPARAMS FAR* pdispparams,

VARIANT FAR* pvarResult,

EXCEPINFO FAR* pexcepinfo,

UINT FAR* puArgErr)

{

HRESULT hr;

if (NULL == pexcepinfo)

return ResultFromScode(E_INVALIDARG);

m_bRaiseException = FALSE;

hr = DispInvoke(

this, m_ptinfo,

dispidMember, wFlags, pdispparams,

pvarResult, pexcepinfo, puArgErr);

if (m_bRaiseException)

{

_fmemcpy(pexcepinfo, &m_excepinfo, sizeof(EXCEPINFO));

return ResultFromScode(DISP_E_EXCEPTION);

}

else return hr;

}

See Also

CreateStdDispatch
, IDispatch::Invoke


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun