2000-12-20 00:29:58 +01:00
|
|
|
/**
|
|
|
|
* Dispatch API functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Francois Jacques, Macadamian Technologies Inc.
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-12-20 00:29:58 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2003-01-05 21:32:30 +01:00
|
|
|
#include "objbase.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "oleauto.h"
|
2000-12-20 00:29:58 +01:00
|
|
|
#include "winerror.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-12-20 00:29:58 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
2000-12-20 00:29:58 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-12 04:49:57 +01:00
|
|
|
* DispInvoke (OLEAUT32.30)
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* Call an object method using the information from its type library.
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: Returns DISP_E_EXCEPTION and updates pexcepinfo if an exception occurs.
|
|
|
|
* DISP_E_BADPARAMCOUNT if the number of parameters is incorrect.
|
|
|
|
* DISP_E_MEMBERNOTFOUND if the method does not exist.
|
|
|
|
* puArgErr is updated if a parameter error (see notes) occurs.
|
|
|
|
* Otherwise, returns the result of calling ITypeInfo_Invoke().
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* NOTES
|
|
|
|
* Parameter errors include the following:
|
|
|
|
*| DISP_E_BADVARTYPE
|
|
|
|
*| E_INVALIDARG An argument was invalid
|
|
|
|
*| DISP_E_TYPEMISMATCH,
|
|
|
|
*| DISP_E_OVERFLOW An argument was valid but could not be coerced
|
|
|
|
*| DISP_E_PARAMNOTOPTIONAL A non optional parameter was not passed
|
|
|
|
*| DISP_E_PARAMNOTFOUND A parameter was passed that was not expected by the method
|
|
|
|
* This call defers to ITypeInfo_Invoke().
|
2000-12-20 00:29:58 +01:00
|
|
|
*/
|
2001-02-12 04:49:57 +01:00
|
|
|
HRESULT WINAPI DispInvoke(
|
2003-03-18 19:35:48 +01:00
|
|
|
VOID *_this, /* [in] Object to call method on */
|
|
|
|
ITypeInfo *ptinfo, /* [in] Object type info */
|
|
|
|
DISPID dispidMember, /* [in] DISPID of the member (e.g. from GetIDsOfNames()) */
|
|
|
|
USHORT wFlags, /* [in] Kind of method call (DISPATCH_ flags from "oaidl.h") */
|
|
|
|
DISPPARAMS *pparams, /* [in] Array of method arguments */
|
|
|
|
VARIANT *pvarResult, /* [out] Destination for the result of the call */
|
|
|
|
EXCEPINFO *pexcepinfo, /* [out] Destination for exception information */
|
|
|
|
UINT *puArgErr) /* [out] Destination for bad argument */
|
2000-12-20 00:29:58 +01:00
|
|
|
{
|
2005-06-01 13:03:05 +02:00
|
|
|
TRACE("\n");
|
2000-12-20 00:29:58 +01:00
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
return ITypeInfo_Invoke(ptinfo, _this, dispidMember, wFlags,
|
|
|
|
pparams, pvarResult, pexcepinfo, puArgErr);
|
2000-12-20 00:29:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-12 04:49:57 +01:00
|
|
|
* DispGetIDsOfNames (OLEAUT32.29)
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
2006-03-21 18:24:49 +01:00
|
|
|
* Convert a set of parameter names to DISPIDs for DispInvoke().
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: An HRESULT error code.
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
2003-03-18 19:35:48 +01:00
|
|
|
* NOTES
|
|
|
|
* This call defers to ITypeInfo_GetIDsOfNames(). The ITypeInfo interface passed
|
2006-03-21 18:24:49 +01:00
|
|
|
* as ptinfo contains the information to map names to DISPIDs.
|
2000-12-20 00:29:58 +01:00
|
|
|
*/
|
2001-02-12 04:49:57 +01:00
|
|
|
HRESULT WINAPI DispGetIDsOfNames(
|
2003-03-18 19:35:48 +01:00
|
|
|
ITypeInfo *ptinfo, /* [in] Object's type info */
|
2006-03-21 18:24:49 +01:00
|
|
|
OLECHAR **rgszNames, /* [in] Array of names to get DISPIDs for */
|
2003-03-18 19:35:48 +01:00
|
|
|
UINT cNames, /* [in] Number of names in rgszNames */
|
2006-03-21 18:24:49 +01:00
|
|
|
DISPID *rgdispid) /* [out] Destination for converted DISPIDs */
|
2000-12-20 00:29:58 +01:00
|
|
|
{
|
2003-03-18 19:35:48 +01:00
|
|
|
return ITypeInfo_GetIDsOfNames(ptinfo, rgszNames, cNames, rgdispid);
|
2000-12-20 00:29:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2001-02-12 04:49:57 +01:00
|
|
|
* DispGetParam (OLEAUT32.28)
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
2006-03-21 18:24:49 +01:00
|
|
|
* Retrieve a parameter from a DISPPARAMS structure and coerce it to the
|
2003-03-18 19:35:48 +01:00
|
|
|
* specified variant type.
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
2003-03-18 19:35:48 +01:00
|
|
|
* Coercion is done using system (0) locale.
|
2000-12-20 00:29:58 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
2003-03-18 19:35:48 +01:00
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: DISP_E_PARAMNOTFOUND, if position is invalid. or
|
|
|
|
* DISP_E_TYPEMISMATCH, if the coercion failed. puArgErr is
|
|
|
|
* set to the index of the argument in pdispparams.
|
2000-12-20 00:29:58 +01:00
|
|
|
*/
|
2001-02-12 04:49:57 +01:00
|
|
|
HRESULT WINAPI DispGetParam(
|
2003-03-18 19:35:48 +01:00
|
|
|
DISPPARAMS *pdispparams, /* [in] Parameter list */
|
|
|
|
UINT position, /* [in] Position of parameter to coerce in pdispparams */
|
|
|
|
VARTYPE vtTarg, /* [in] Type of value to coerce to */
|
|
|
|
VARIANT *pvarResult, /* [out] Destination for resulting variant */
|
|
|
|
UINT *puArgErr) /* [out] Destination for error code */
|
2000-12-20 00:29:58 +01:00
|
|
|
{
|
2001-10-01 22:53:11 +02:00
|
|
|
/* position is counted backwards */
|
|
|
|
UINT pos;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
|
|
|
|
position, pdispparams->cArgs, pdispparams->cNamedArgs);
|
2009-12-05 02:14:52 +01:00
|
|
|
|
2009-12-05 02:15:11 +01:00
|
|
|
if (position < pdispparams->cArgs)
|
|
|
|
{
|
2001-10-01 22:53:11 +02:00
|
|
|
/* positional arg? */
|
|
|
|
pos = pdispparams->cArgs - position - 1;
|
2009-12-05 02:15:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-10-01 22:53:11 +02:00
|
|
|
/* FIXME: is this how to handle named args? */
|
|
|
|
for (pos=0; pos<pdispparams->cNamedArgs; pos++)
|
|
|
|
if (pdispparams->rgdispidNamedArgs[pos] == position) break;
|
|
|
|
|
|
|
|
if (pos==pdispparams->cNamedArgs)
|
|
|
|
return DISP_E_PARAMNOTFOUND;
|
|
|
|
}
|
2009-12-05 02:15:11 +01:00
|
|
|
|
|
|
|
if (pdispparams->cArgs > 0 && !pdispparams->rgvarg)
|
|
|
|
{
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pvarResult)
|
|
|
|
{
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2001-10-01 22:53:11 +02:00
|
|
|
hr = VariantChangeType(pvarResult,
|
|
|
|
&pdispparams->rgvarg[pos],
|
|
|
|
0, vtTarg);
|
2009-12-05 02:15:11 +01:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (FAILED(hr))
|
|
|
|
*puArgErr = pos;
|
|
|
|
|
2001-10-01 22:53:11 +02:00
|
|
|
return hr;
|
2000-12-20 00:29:58 +01:00
|
|
|
}
|
2002-12-12 23:24:45 +01:00
|
|
|
|
2002-12-17 02:47:27 +01:00
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch {OLEAUT32}
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The IDispatch interface provides a single interface to dispatch method calls,
|
|
|
|
* regardless of whether the object to be called is in or out of process,
|
|
|
|
* local or remote (e.g. being called over a network). This interface is late-bound
|
|
|
|
* (linked at run-time), as opposed to early-bound (linked at compile time).
|
|
|
|
*
|
|
|
|
* The interface is used by objects that wish to called by scripting
|
2019-12-12 11:24:05 +01:00
|
|
|
* languages such as VBA, in order to minimize the amount of COM and C/C++
|
2003-03-18 19:35:48 +01:00
|
|
|
* knowledge required, or by objects that wish to live out of process from code
|
|
|
|
* that will call their methods.
|
|
|
|
*
|
|
|
|
* Method, property and parameter names can be localised. The details required to
|
|
|
|
* map names to methods and parameters are collected in a type library, usually
|
|
|
|
* output by an IDL compiler using the objects IDL description. This information is
|
2008-04-11 01:24:54 +02:00
|
|
|
* accessible programmatically through the ITypeLib interface (for a type library),
|
2003-03-18 19:35:48 +01:00
|
|
|
* and the ITypeInfo interface (for an object within the type library). Type information
|
|
|
|
* can also be created at run-time using CreateDispTypeInfo().
|
|
|
|
*
|
|
|
|
* WRAPPERS
|
|
|
|
* Instead of using IDispatch directly, there are several wrapper functions available
|
|
|
|
* to simplify the process of calling an objects methods through IDispatch.
|
|
|
|
*
|
|
|
|
* A standard implementation of an IDispatch object is created by calling
|
2006-03-21 18:24:49 +01:00
|
|
|
* CreateStdDispatch(). Numeric Id values for the parameters and methods (DISPIDs)
|
2003-03-18 19:35:48 +01:00
|
|
|
* of an object of interest are retrieved by calling DispGetIDsOfNames(). DispGetParam()
|
|
|
|
* retrieves information about a particular parameter. Finally the DispInvoke()
|
2006-03-21 18:24:49 +01:00
|
|
|
* function is responsible for actually calling methods on an object.
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* METHODS
|
|
|
|
*/
|
|
|
|
|
2002-12-17 02:47:27 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
IDispatch IDispatch_iface;
|
2002-12-17 02:47:27 +01:00
|
|
|
void * pvThis;
|
|
|
|
ITypeInfo * pTypeInfo;
|
2005-07-11 12:25:19 +02:00
|
|
|
LONG ref;
|
2002-12-17 02:47:27 +01:00
|
|
|
} StdDispatch;
|
|
|
|
|
2010-12-04 22:16:07 +01:00
|
|
|
static inline StdDispatch *impl_from_IDispatch(IDispatch *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, StdDispatch, IDispatch_iface);
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_QueryInterface {OLEAUT32}
|
|
|
|
*
|
|
|
|
* See IUnknown_QueryInterface.
|
|
|
|
*/
|
2002-12-17 02:47:27 +01:00
|
|
|
static HRESULT WINAPI StdDispatch_QueryInterface(
|
|
|
|
LPDISPATCH iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
StdDispatch *This = impl_from_IDispatch(iface);
|
2014-01-29 05:19:53 +01:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
2002-12-17 02:47:27 +01:00
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDispatch) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
2014-01-29 05:19:53 +01:00
|
|
|
*ppvObject = iface;
|
|
|
|
IDispatch_AddRef(iface);
|
2009-12-05 02:15:11 +01:00
|
|
|
return S_OK;
|
2002-12-17 02:47:27 +01:00
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_AddRef {OLEAUT32}
|
|
|
|
*
|
|
|
|
* See IUnknown_AddRef.
|
|
|
|
*/
|
2002-12-17 02:47:27 +01:00
|
|
|
static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface)
|
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
StdDispatch *This = impl_from_IDispatch(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2003-07-09 06:18:51 +02:00
|
|
|
|
2022-02-12 14:34:59 +01:00
|
|
|
TRACE("%p, refcount %lu.\n", iface, refCount);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
|
|
|
return refCount;
|
2002-12-17 02:47:27 +01:00
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_Release {OLEAUT32}
|
|
|
|
*
|
|
|
|
* See IUnknown_Release.
|
|
|
|
*/
|
2002-12-17 02:47:27 +01:00
|
|
|
static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface)
|
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
StdDispatch *This = impl_from_IDispatch(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2002-12-17 02:47:27 +01:00
|
|
|
|
2022-02-12 14:34:59 +01:00
|
|
|
TRACE("%p, refcount %lu.\n", iface, refCount);
|
2002-12-17 02:47:27 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
if (!refCount)
|
2003-07-09 06:18:51 +02:00
|
|
|
{
|
|
|
|
ITypeInfo_Release(This->pTypeInfo);
|
2002-12-17 02:47:27 +01:00
|
|
|
CoTaskMemFree(This);
|
2003-07-09 06:18:51 +02:00
|
|
|
}
|
2002-12-17 02:47:27 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2002-12-17 02:47:27 +01:00
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_GetTypeInfoCount {OLEAUT32}
|
|
|
|
*
|
|
|
|
* Get the count of type information in an IDispatch interface.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IDispatch interface
|
|
|
|
* pctinfo [O] Destination for the count
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. pctinfo is updated with the count. This is always 1 if
|
|
|
|
* the object provides type information, and 0 if it does not.
|
|
|
|
* Failure: E_NOTIMPL. The object does not provide type information.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See IDispatch() and IDispatch_GetTypeInfo().
|
|
|
|
*/
|
2002-12-17 02:47:27 +01:00
|
|
|
static HRESULT WINAPI StdDispatch_GetTypeInfoCount(LPDISPATCH iface, UINT * pctinfo)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", pctinfo);
|
2014-01-29 05:19:53 +01:00
|
|
|
*pctinfo = 1;
|
2002-12-17 02:47:27 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_GetTypeInfo {OLEAUT32}
|
|
|
|
*
|
|
|
|
* Get type information from an IDispatch interface.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IDispatch interface
|
|
|
|
* iTInfo [I] Index of type information.
|
|
|
|
* lcid [I] Locale of the type information to get
|
|
|
|
* ppTInfo [O] Destination for the ITypeInfo object
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. ppTInfo is updated with the objects type information
|
|
|
|
* Failure: DISP_E_BADINDEX, if iTInfo is any value other than 0.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See IDispatch.
|
|
|
|
*/
|
2002-12-17 02:47:27 +01:00
|
|
|
static HRESULT WINAPI StdDispatch_GetTypeInfo(LPDISPATCH iface, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo)
|
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
StdDispatch *This = impl_from_IDispatch(iface);
|
2022-02-12 14:34:59 +01:00
|
|
|
|
|
|
|
TRACE("%d, %#lx, %p.\n", iTInfo, lcid, ppTInfo);
|
2002-12-17 02:47:27 +01:00
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
*ppTInfo = NULL;
|
2002-12-17 02:47:27 +01:00
|
|
|
if (iTInfo != 0)
|
|
|
|
return DISP_E_BADINDEX;
|
2003-03-18 19:35:48 +01:00
|
|
|
|
2014-01-29 05:19:53 +01:00
|
|
|
*ppTInfo = This->pTypeInfo;
|
|
|
|
ITypeInfo_AddRef(*ppTInfo);
|
|
|
|
|
2002-12-17 02:47:27 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_GetIDsOfNames {OLEAUT32}
|
|
|
|
*
|
2006-03-21 18:24:49 +01:00
|
|
|
* Convert a methods name and an optional set of parameter names into DISPIDs
|
2003-03-18 19:35:48 +01:00
|
|
|
* for passing to IDispatch_Invoke().
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IDispatch interface
|
|
|
|
* riid [I] Reserved, set to IID_NULL
|
|
|
|
* rgszNames [I] Name to convert
|
|
|
|
* cNames [I] Number of names in rgszNames
|
|
|
|
* lcid [I] Locale of the type information to convert from
|
2006-03-21 18:24:49 +01:00
|
|
|
* rgDispId [O] Destination for converted DISPIDs.
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: DISP_E_UNKNOWNNAME, if any of the names is invalid.
|
|
|
|
* DISP_E_UNKNOWNLCID if lcid is invalid.
|
2006-10-15 17:05:01 +02:00
|
|
|
* Otherwise, an HRESULT error code.
|
2003-03-18 19:35:48 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* This call defers to ITypeInfo_GetIDsOfNames(), using the ITypeInfo object
|
|
|
|
* contained within the IDispatch object.
|
|
|
|
* The first member of the names list must be a method name. The names following
|
|
|
|
* the method name are the parameters for that method.
|
|
|
|
*/
|
2002-12-17 02:47:27 +01:00
|
|
|
static HRESULT WINAPI StdDispatch_GetIDsOfNames(LPDISPATCH iface, REFIID riid, LPOLESTR * rgszNames, UINT cNames, LCID lcid, DISPID * rgDispId)
|
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
StdDispatch *This = impl_from_IDispatch(iface);
|
2022-02-12 14:34:59 +01:00
|
|
|
|
|
|
|
TRACE("%s, %p, %d, %#lx, %p.\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
|
2002-12-17 02:47:27 +01:00
|
|
|
|
|
|
|
if (!IsEqualGUID(riid, &IID_NULL))
|
|
|
|
{
|
|
|
|
FIXME(" expected riid == IID_NULL\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
return DispGetIDsOfNames(This->pTypeInfo, rgszNames, cNames, rgDispId);
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:35:48 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* IDispatch_Invoke {OLEAUT32}
|
|
|
|
*
|
|
|
|
* Call an object method.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* iface [I] IDispatch interface
|
|
|
|
* dispIdMember [I] DISPID of the method (from GetIDsOfNames())
|
|
|
|
* riid [I] Reserved, set to IID_NULL
|
|
|
|
* lcid [I] Locale of the type information to convert parameters with
|
|
|
|
* wFlags, [I] Kind of method call (DISPATCH_ flags from "oaidl.h")
|
|
|
|
* pDispParams [I] Array of method arguments
|
|
|
|
* pVarResult [O] Destination for the result of the call
|
|
|
|
* pExcepInfo [O] Destination for exception information
|
|
|
|
* puArgErr [O] Destination for bad argument
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK.
|
|
|
|
* Failure: See DispInvoke() for failure cases.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* See DispInvoke() and IDispatch().
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI StdDispatch_Invoke(LPDISPATCH iface, DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS * pDispParams, VARIANT * pVarResult,
|
|
|
|
EXCEPINFO * pExcepInfo, UINT * puArgErr)
|
2002-12-17 02:47:27 +01:00
|
|
|
{
|
2010-12-04 22:16:07 +01:00
|
|
|
StdDispatch *This = impl_from_IDispatch(iface);
|
2022-02-12 14:34:59 +01:00
|
|
|
|
|
|
|
TRACE("%ld, %s, %#lx, 0x%x, %p, %p, %p, %p.\n", dispIdMember, debugstr_guid(riid), lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2002-12-17 02:47:27 +01:00
|
|
|
|
|
|
|
if (!IsEqualGUID(riid, &IID_NULL))
|
|
|
|
{
|
|
|
|
FIXME(" expected riid == IID_NULL\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
return DispInvoke(This->pvThis, This->pTypeInfo, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IDispatchVtbl StdDispatch_VTable =
|
2002-12-17 02:47:27 +01:00
|
|
|
{
|
|
|
|
StdDispatch_QueryInterface,
|
|
|
|
StdDispatch_AddRef,
|
|
|
|
StdDispatch_Release,
|
|
|
|
StdDispatch_GetTypeInfoCount,
|
|
|
|
StdDispatch_GetTypeInfo,
|
|
|
|
StdDispatch_GetIDsOfNames,
|
|
|
|
StdDispatch_Invoke
|
|
|
|
};
|
|
|
|
|
2014-01-29 05:19:33 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* CreateStdDispatch [OLEAUT32.32]
|
|
|
|
*
|
|
|
|
* Create and return a standard IDispatch object.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK. ppunkStdDisp contains the new object.
|
|
|
|
* Failure: An HRESULT error code.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Outer unknown appears to be completely ignored.
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CreateStdDispatch(
|
|
|
|
IUnknown* punkOuter,
|
|
|
|
void* pvThis,
|
|
|
|
ITypeInfo* ptinfo,
|
|
|
|
IUnknown** stddisp)
|
2002-12-17 02:47:27 +01:00
|
|
|
{
|
2014-01-29 05:19:33 +01:00
|
|
|
StdDispatch *pStdDispatch;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %p)\n", punkOuter, pvThis, ptinfo, stddisp);
|
|
|
|
|
|
|
|
if (!pvThis || !ptinfo || !stddisp)
|
|
|
|
return E_INVALIDARG;
|
2002-12-17 02:47:27 +01:00
|
|
|
|
|
|
|
pStdDispatch = CoTaskMemAlloc(sizeof(StdDispatch));
|
|
|
|
if (!pStdDispatch)
|
2014-01-29 05:19:33 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2002-12-17 02:47:27 +01:00
|
|
|
|
2010-12-04 22:16:07 +01:00
|
|
|
pStdDispatch->IDispatch_iface.lpVtbl = &StdDispatch_VTable;
|
2002-12-17 02:47:27 +01:00
|
|
|
pStdDispatch->pvThis = pvThis;
|
2014-01-29 05:19:33 +01:00
|
|
|
pStdDispatch->pTypeInfo = ptinfo;
|
2002-12-17 02:47:27 +01:00
|
|
|
pStdDispatch->ref = 1;
|
|
|
|
|
2003-07-09 06:18:51 +02:00
|
|
|
/* we keep a reference to the type info so prevent it from
|
|
|
|
* being destroyed until we are done with it */
|
2014-01-29 05:19:33 +01:00
|
|
|
ITypeInfo_AddRef(ptinfo);
|
|
|
|
*stddisp = (IUnknown*)&pStdDispatch->IDispatch_iface;
|
2003-07-09 06:18:51 +02:00
|
|
|
|
2014-01-29 05:19:33 +01:00
|
|
|
return S_OK;
|
2002-12-17 02:47:27 +01:00
|
|
|
}
|