コード例 #1
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod |PyIDispatchEx|DeleteMemberByDispID|
PyObject *PyIDispatchEx::DeleteMemberByDispID(PyObject *self, PyObject *args)
{
	long dispid;
	if (!PyArg_ParseTuple(args, "ll:DeleteMemberByDispID",
		&dispid)) // @pyparm int|dispid||
		return NULL;
	IDispatchEx *pMyDispatchEx = GetI(self);
	if (pMyDispatchEx==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatchEx->DeleteMemberByDispID((DISPID)dispid);
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return SetPythonCOMError(self, hr);
	Py_INCREF(Py_None);
	return Py_None;
}
コード例 #2
0
ファイル: ExplorerElement.cpp プロジェクト: SoffidIAM/esso
static HRESULT getDispatchProperty (IDispatch *object, const char *property, VARIANT &value)
{
	BSTR bstr = Utils::str2bstr(property);
	DISPID dispId;
	IDispatchEx *pDispatchEx;
	static IID IDispatchEx_CLSID = { 0xa6ef9860, 0xc720, 0x11d0, {0x93, 0x37, 0x00,0xa0,0xc9,0x0d,0xca,0xa9}};
	HRESULT hr = object->QueryInterface(IDispatchEx_CLSID, reinterpret_cast<void**>(&pDispatchEx)) ;
	if (! FAILED (hr) && pDispatchEx != NULL)
	{
		hr = pDispatchEx->GetDispID(bstr, fdexNameEnsure, &dispId);
		if (FAILED (hr))
		{
			MZNSendDebugMessage("Unable to get property %ls", bstr);
		}
		else
		{
			DISPPARAMS dp;
			dp.cArgs = 0;
			dp.cNamedArgs = 0;
			dp.rgvarg = NULL;
			VARIANT result ;
			result.vt = VT_NULL;
			UINT error;
			EXCEPINFO ei;
			ZeroMemory (&ei, sizeof ei);
			hr = pDispatchEx->InvokeEx(dispId, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dp, &value, &ei, NULL);
			if ( FAILED(hr))
			{
#if 0
				MZNSendDebugMessage("Cannot get property %s", property);
				MZNSendDebugMessage("Error en InvokeEx");
				MZNSendDebugMessage("Error en %lX en attributes %d", (long) hr,  (int) error);
				MZNSendDebugMessage("Error code %d ", (int) ei.wCode);
				MZNSendDebugMessage("Source %ls", ei.bstrSource);
				MZNSendDebugMessage("Description %ls", ei.bstrDescription);
#endif
			}

		}
		pDispatchEx -> Release();
	}
	else
	{
		MZNSendDebugMessage("Cannot get IDispatchEx");
	}
	SysFreeString(bstr);
	return hr;
}
コード例 #3
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod str|PyIDispatchEx|GetMemberName|Returns the name associated with a member id
PyObject *PyIDispatchEx::GetMemberName(PyObject *self, PyObject *args)
{
	long dispid;
	BSTR name;
	if (!PyArg_ParseTuple(args, "l:GetMemberName",
		&dispid)) // @pyparm int|dispid||The member id
		return NULL;
	IDispatchEx *pMyDispatchEx = GetI(self);
	if (pMyDispatchEx==NULL) return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatchEx->GetMemberName(dispid, &name);
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return SetPythonCOMError(self, hr);
	return PyWinObject_FromBstr(name, TRUE);
}
コード例 #4
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod int|PyIDispatchEx|GetNextDispID|Enumerates member ids.
PyObject *PyIDispatchEx::GetNextDispID(PyObject *self, PyObject *args)
{
	long fdex;
	long dispid;
	if (!PyArg_ParseTuple(args, "ll:GetNextDispID",
		&fdex, // @pyparm int|fdex||Determines the options
		&dispid)) // @pyparm int|dispid||Current member, or DISPID_STARTENUM to begin enumeration. GetNextDispID will retrieve the item in the enumeration after this one. 
		return NULL;
	IDispatchEx *pMyDispatchEx = GetI(self);
	if (pMyDispatchEx==NULL) return NULL;
	DISPID retDispid;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatchEx->GetNextDispID((DWORD)fdex, (DISPID)dispid, &retDispid);
	PY_INTERFACE_POSTCALL;
	if (hr != S_OK) return SetPythonCOMError(self, hr);
	return PyInt_FromLong(retDispid);
}
コード例 #5
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod int|PyIDispatchEx|GetMemberProperties|Returns mask of fdex* flags describing a member
PyObject *PyIDispatchEx::GetMemberProperties(PyObject *self, PyObject *args)
{
	long fdex;
	long dispid;
	if (!PyArg_ParseTuple(args, "ll:GetMemberProperties",
		&dispid, // @pyparm int|dispid||The member id
		&fdex)) // @pyparm int|fdex||fdex* flags specifying which properties to return
		return NULL;
	IDispatchEx *pMyDispatchEx = GetI(self);
	if (pMyDispatchEx==NULL) return NULL;
	DWORD props;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatchEx->GetMemberProperties((DISPID)dispid, (DWORD)fdex, &props);
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return SetPythonCOMError(self, hr);
	return PyInt_FromLong(props);
}
コード例 #6
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod |PyIDispatchEx|DeleteMemberByName|
PyObject *PyIDispatchEx::DeleteMemberByName(PyObject *self, PyObject *args)
{
	long fdex;
	PyObject *obName;
	if (!PyArg_ParseTuple(args, "Ol:DeleteMemberByName",
		&obName, // @pyparm <o PyUnicode>|name||Passed in name to be mapped
		&fdex)) // @pyparm int|fdex||Determines the options 
		return NULL;
	PyWin_AutoFreeBstr name;
	if (!PyWinObject_AsAutoFreeBstr(obName, &name))
		return NULL;
	IDispatchEx *pMyDispatchEx = GetI(self);
	if (pMyDispatchEx==NULL) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatchEx->DeleteMemberByName(name, (DWORD)fdex);
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return SetPythonCOMError(self, hr);
	Py_INCREF(Py_None);
	return Py_None;
}
コード例 #7
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod int|PyIDispatchEx|GetDispID|Returns the member id for a name
PyObject *PyIDispatchEx::GetDispID(PyObject *self, PyObject *args)
{
	long fdex;
	PyObject *obName;
	if (!PyArg_ParseTuple(args, "Ol:GetDispId",
		&obName, // @pyparm <o PyUnicode>|name||Passed in name to be mapped
		&fdex)) // @pyparm int|fdex||Determines the options for obtaining the member identifier. This can be a combination of the fdex* constants:
		return NULL;
	PyWin_AutoFreeBstr name;
	if (!PyWinObject_AsAutoFreeBstr(obName, &name))
		return NULL;
	IDispatchEx *pMyDispatchEx = GetI(self);
	if (pMyDispatchEx==NULL) return NULL;
	DISPID dispid;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatchEx->GetDispID(name, (DWORD)fdex, &dispid);
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return SetPythonCOMError(self, hr);
	return PyInt_FromLong(dispid);
}
コード例 #8
0
ファイル: ExplorerElement.cpp プロジェクト: SoffidIAM/esso
static HRESULT setDispatchProperty (IDispatch *object, const char *property, VARIANT &value)
{
	BSTR bstr = Utils::str2bstr(property);
	DISPID dispId;
	IDispatchEx *pDispatchEx;
	static IID IDispatchEx_CLSID = { 0xa6ef9860, 0xc720, 0x11d0, {0x93, 0x37, 0x00,0xa0,0xc9,0x0d,0xca,0xa9}};
	HRESULT hr = object->QueryInterface(IDispatchEx_CLSID, reinterpret_cast<void**>(&pDispatchEx)) ;
	if (! FAILED (hr) && pDispatchEx != NULL)
	{
		hr = pDispatchEx->GetDispID(bstr, fdexNameEnsure, &dispId);
		if (FAILED (hr))
		{
			MZNSendDebugMessage("Unable to create property %ls", bstr);
		}
		else
		{
			DISPPARAMS dp;
			dp.cArgs = 1;
			dp.cNamedArgs = 0;
			dp.rgvarg = &value;
			VARIANT result ;
			result.vt = VT_NULL;
			UINT error;
			hr = pDispatchEx->InvokeEx(dispId, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT, &dp, &result, NULL, NULL);

			if ( !FAILED(hr))
			{
			}
			else
				MZNSendDebugMessage("Error en InvokeEx");

		}
		pDispatchEx -> Release();
	}
	else
	{
		MZNSendDebugMessage("Cannot get IDispatchEx");
	}
	SysFreeString(bstr);
	return hr;
}
コード例 #9
0
ファイル: itemdisp.cpp プロジェクト: arton/RScript19
IDispatch* CItemHolder::GetDispatch(IActiveScriptSite* pSite, LPOLESTR pstrName, bool fSameApt)
{
	IDispatchEx* pDispEx = m_pDispEx;
	IDispatch* pDisp = m_pDisp;
	ATLTRACE(_("CItemHolder::GetDispatch in Thread:%08X name=%ls sameptr=%d\n"), GetCurrentThreadId(), pstrName, fSameApt);
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
	if (fSameApt)
	{
#endif
		if (pDisp == NULL && pDispEx == NULL)
		{
			ATLTRACE(_("CItemHolder::GetDispatch in Thread:%08X\n"), GetCurrentThreadId());
			IUnknown* pUnk = NULL;
			ITypeInfo* pTypeInfo = NULL;
			HRESULT hr = pSite->GetItemInfo(pstrName, SCRIPTINFO_IUNKNOWN, &pUnk, &pTypeInfo);
			if (hr == S_OK)
			{
				if (pTypeInfo) pTypeInfo->Release();
				if (pUnk->QueryInterface(IID_IDispatchEx, (void**)&pDispEx) == S_OK)
				{
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
					HRESULT hr = m_pGIPDispEx.Globalize(pDispEx);
					ATLTRACE(_T("Globalize Item = %08X\n"), hr);
#endif
					m_pDispEx = pDispEx;
				}
				else
				{
					pDispEx = NULL;
					if (pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp) == S_OK)
					{
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
						HRESULT hr = m_pGIPDisp.Globalize(pDisp);
						ATLTRACE(_T("Globalize Item = %08X\n"), hr);
#endif
						m_pDisp = pDisp;
					}
				}
				pUnk->Release();
			}
		}

		if (pDispEx)
		{
			pDispEx->AddRef();
		}
		else if (pDisp)
		{
			pDisp->AddRef();
		}
#ifdef __IRubyWrapper_INTERFACE_DEFINED__
	}
	else
	{
		if (m_pGIPDisp.IsOK() == false && m_pGIPDispEx.IsOK() == false)
		{
			ATLTRACE(_("CItemHolder::GetDispatch in Thread:%08X\n"), GetCurrentThreadId());
			IUnknown* pUnk = NULL;
			ITypeInfo* pTypeInfo = NULL;
			HRESULT hr = pSite->GetItemInfo(pstrName, SCRIPTINFO_IUNKNOWN, &pUnk, &pTypeInfo);
			if (hr == S_OK)
			{
				if (pTypeInfo) pTypeInfo->Release();
				if (pUnk->QueryInterface(IID_IDispatchEx, (void**)&pDispEx) != S_OK)
				{
					pDispEx = NULL;
					if (pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp) != S_OK)
					{
						pDisp = NULL;
					}
				}
				pUnk->Release();
			}
		}
		if (m_pGIPDispEx.IsOK())
		{
			IDispatchEx* p;
			HRESULT hr = m_pGIPDispEx.Localize(&p);
			ATLTRACE(_("Localize DispEx = %08X\n"), hr);
			return p;
		}
		if (m_pGIPDisp.IsOK())
		{
			IDispatch* p;
			HRESULT hr = m_pGIPDisp.Localize(&p);
			ATLTRACE(_("Localize Disp = %08X\n"), hr);
			return p;
		}
	}
#endif
	return (pDispEx) ? pDispEx : pDisp;
}
コード例 #10
0
ファイル: PyIDispatch.cpp プロジェクト: malrsrch/pywin32
// @pymethod object|PyIDispatchEx|InvokeEx|Provides access to properties and methods exposed by a <o PyIDispatchEx> object. 
PyObject *PyIDispatchEx::InvokeEx(PyObject *self, PyObject *args)
{
	long dispid;
	long lcid;
	int flags;
	PyObject *invokeArgs;
	PyObject *types = Py_None;
	PyObject *obReturnDesc = Py_None;
	PyObject *obCaller = Py_None;
	if (!PyArg_ParseTuple(args, "lliO|OOO:InvokeEx",
		&dispid, // @pyparm int|dispid||
		&lcid,  // @pyparm int|lcid||
		&flags, // @pyparm int|flags||
		&invokeArgs,  // @pyparm [object, ...]|args||The arguments.
		&types, // @pyparm [object, ...]|types|None|A tuple of type description object, or None if type descriptions are not available.
		&obReturnDesc, // @pyparm object\|int|returnDesc|1|If types==None, should be a BOOL indicating if the result is needed.  If types is a tuple, then should a be type description.
		&obCaller)) // @pyparm <o PyIServiceProvider>|serviceProvider|None|A service provider object supplied by the caller which allows the object to obtain services from the caller. Can be None.
		return NULL;

	if (!PyTuple_Check(invokeArgs)) {
		PyErr_SetString(PyExc_TypeError, "The arguments must be a tuple.");
		return NULL;
	}

	// TODO - We do not yet support the Type Description here
	// (Im not even sure if we need it!)
	if (types != Py_None || obReturnDesc != Py_None) {
		PyErr_SetString(PyExc_TypeError, "Type descriptions are not yet supported.");
		return NULL;
	}
	// TODO - Add support for PyIServiceProvider
	if (obCaller != Py_None) {
		PyErr_SetString(PyExc_TypeError, "If you really need IServiceProvider support, you are going to have to add it!.");
		return NULL;
	}
	BOOL bResultWanted = TRUE;

	IDispatchEx *pMyDispatch = GetI(self);
	if ( pMyDispatch==NULL )
		return NULL;

	DISPPARAMS dispparams;
	PythonOleArgHelper *helpers;
	if (!PyCom_MakeUntypedDISPPARAMS(invokeArgs, PyObject_Length(invokeArgs), flags, &dispparams, &helpers ))
		return NULL;

	VARIANT varResult;
	VARIANT *pVarResultUse;
	if ( bResultWanted ) {
		VariantInit(&varResult);
		pVarResultUse = &varResult;
	} else
		pVarResultUse = NULL;

	// initialize EXCEPINFO struct
	EXCEPINFO excepInfo;
	memset(&excepInfo, 0, sizeof excepInfo);

	PY_INTERFACE_PRECALL;
	HRESULT hr = pMyDispatch->InvokeEx((DISPID)dispid, (LCID)lcid, (WORD)flags, &dispparams, pVarResultUse, &excepInfo, NULL);
	PY_INTERFACE_POSTCALL;

	if (!PyCom_FinishUntypedDISPPARAMS(&dispparams, helpers) ||
	    HandledDispatchFailure(hr, &excepInfo, (UINT)-1, dispparams.cArgs) ) {
		if ( pVarResultUse )
			VariantClear(pVarResultUse);
		return NULL;
	}

	PyObject *result;
	if (pVarResultUse) {
		result = PyCom_PyObjectFromVariant(pVarResultUse);
		VariantClear(pVarResultUse);
	} else {
		result = Py_None;
		Py_INCREF(result);
	}
	return result;
}