示例#1
0
void tLuaCOM::releaseConnections() {
	if(conn_point==NULL)
		return;
	
	conn_point->Release();
	IConnectionPointContainer *pcpc;

    HRESULT hr = pdisp->QueryInterface(IID_IConnectionPointContainer, (void **) &pcpc);

    if(FAILED(hr))
    {
	    return;
    }

	IEnumConnectionPoints *pecp;

	hr = pcpc->EnumConnectionPoints(&pecp);
	pcpc->Release();

    if(FAILED(hr))
    {
	    return;
    }

	pecp->Reset();

	IConnectionPoint *pcp;
	ULONG fetched = 0;

	hr = pecp->Next(1, &pcp, &fetched);
	while(SUCCEEDED(hr) && fetched) {
		IEnumConnections *pec;
		hr = pcp->EnumConnections(&pec);
		if(SUCCEEDED(hr)) {
			pec->Reset();
			CONNECTDATA conn;
			ULONG conn_fetched = 0;
			hr = pec->Next(1, &conn, &conn_fetched);
			while(SUCCEEDED(hr) && conn_fetched) {
				pcp->Unadvise(conn.dwCookie);
				hr = pec->Next(1, &conn, &conn_fetched);
			}
			pec->Release();
		}
        pcp->Release();
  	    pecp->Next(1, &pcp, &fetched);
	}
	
	pecp->Release();
}
示例#2
0
HRESULT CJSExtender::SinkObject(CString strPrefix, IDispatch *pUnk, LCID lcid)
{
	if (!pUnk || strPrefix==_T(""))
		return E_INVALIDARG;

	HRESULT hr = S_FALSE;
	GUID iid = GUID_NULL;

	if (theApp.m_pEventProxy) 
		theApp.m_pEventProxy->GetConnectionInterface(&iid);
	else
	{
		CComQIPtr<IConnectionPointContainer> pContainer(pUnk);
		if (pContainer == nullptr)
			return 0;
		GUID libid;
		WORD wMajorVer = 1;
		WORD wMinorVer = 0;
		hr = AtlGetObjectSourceInterface(pUnk, &libid, &iid, &wMajorVer, &wMinorVer);
		if (iid == GUID_NULL)
		{
			IConnectionPoint* pConnectionPoint = nullptr;
			IEnumConnectionPoints* pEnum = nullptr;
			HRESULT hr = pContainer->EnumConnectionPoints(&pEnum);
			if (pEnum)
			{
				ULONG uFetched;
				while (S_OK == (pEnum->Next(1, &pConnectionPoint, &uFetched)) && uFetched >= 1)
				{
					hr = pConnectionPoint->GetConnectionInterface(&iid);
					if (hr == S_OK)
					{
						pConnectionPoint->Release();
						pConnectionPoint = nullptr;
						break;
					}
					pConnectionPoint->Release();
					pConnectionPoint = nullptr;
				}
				pEnum->Release();
			}
		}
	}
	if (iid != GUID_NULL)
		new CJSProxyObj(this, pUnk, iid, strPrefix);

	return S_OK;
}
示例#3
0
// @pymethod (<o PyIConnectionPoint>, ...)|PyIEnumConnectionPoints|Next|Retrieves a specified number of items in the enumeration sequence.
PyObject *PyIEnumConnectionPoints::Next(PyObject *self, PyObject *args)
{
	long celt = 1;
	// @pyparm int|num|1|Number of items to retrieve.
	if ( !PyArg_ParseTuple(args, "|l:Next", &celt) )
		return NULL;

	IEnumConnectionPoints *pIEConnections = GetI(self);
	if ( pIEConnections == NULL )
		return NULL;

	IConnectionPoint **rgVar = new IConnectionPoint *[celt];
	if ( rgVar == NULL ) {
		PyErr_SetString(PyExc_MemoryError, "allocating result array");
		return NULL;
	}
	memset(rgVar, 0, sizeof(IConnectionPoint *)*celt);

	int i;
	ULONG celtFetched = 0;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIEConnections->Next(celt, rgVar, &celtFetched);
	PY_INTERFACE_POSTCALL;
	if (  HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) )
	{
		delete [] rgVar;
		return PyCom_BuildPyException(hr);
	}

	PyObject *result = PyTuple_New(celtFetched);
	if ( result != NULL )
	{
		for ( i = celtFetched; i--; )
		{
			PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IConnectionPoint, FALSE);
			if ( ob == NULL )
			{
				Py_DECREF(result);
				result = NULL;
				break;
			}
			PyTuple_SET_ITEM(result, i, ob);
		}
	}
	delete [] rgVar;
	return result;
}
示例#4
0
// @pymethod <o PyIEnumConnectionPoints>|PyIEnumConnectionPoints|Clone|Creates another enumerator that contains the same enumeration state as the current one
PyObject *PyIEnumConnectionPoints::Clone(PyObject *self, PyObject *args)
{
	if ( !PyArg_ParseTuple(args, ":Clone") )
		return NULL;

	IEnumConnectionPoints *pIEConnections = GetI(self);
	if ( pIEConnections == NULL )
		return NULL;

	IEnumConnectionPoints *pClone;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIEConnections->Clone(&pClone);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr);

	return PyCom_PyObjectFromIUnknown(pClone, IID_IEnumConnectionPoints, FALSE);
}
示例#5
0
// @pymethod |PyIEnumConnectionPoints|Reset|Resets the enumeration sequence to the beginning.
PyObject *PyIEnumConnectionPoints::Reset(PyObject *self, PyObject *args)
{
	if ( !PyArg_ParseTuple(args, ":Reset") )
		return NULL;

	IEnumConnectionPoints *pIEConnections = GetI(self);
	if ( pIEConnections == NULL )
		return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIEConnections->Reset();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr);

	Py_INCREF(Py_None);
	return Py_None;
}
示例#6
0
void EnumConnectionPoint(IDispatch *pDisp, LPCSTR comment)
{
	if (!pDisp) return;
	HRESULT hr = S_OK;

	USES_CONVERSION;
	IConnectionPointContainer *spCPC = NULL;
	IConnectionPoint *spCP = NULL;
	IEnumConnectionPoints *ppEnum = NULL;
	IID id;
	LPOLESTR strGUID = 0;
	CComBSTR bstrId = NULL;

	if(comment) cout << comment << _T(" ");
	cout << _T("ConnectionPoint: [");
	hr = pDisp->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void**>(&spCPC));
	if (SUCCEEDED(hr) && spCPC)
	{
		hr = spCPC->EnumConnectionPoints(&ppEnum);
		while(SUCCEEDED(ppEnum->Next(1, &spCP, NULL)) && spCP) 
		{
			spCP->GetConnectionInterface(&id);
			// 注意此处StringFromIID的正确用法, 否则会在Debug状态下出错: user breakpoint called from code 0x7c901230
			StringFromIID(id, &strGUID);
			bstrId = strGUID;
			CoTaskMemFree(strGUID);
			cout << (bstrId ? OLE2CT(bstrId) : _T("")) << _T(", ");
		}
	}
	cout << "]" << endl;
	if(spCP) spCP->Release();
	if(ppEnum) ppEnum->Release();
	if(spCPC) spCPC->Release();
/*
	{9bfbbc02-eff1-101a-84ed-00aa00341d07}	IPropertyNotifySink
	{3050f3c4-98b5-11cf-bb82-00aa00bdce0b}	HTMLObjectElementEvents
	{3050f620-98b5-11cf-bb82-00aa00bdce0b}	HTMLObjectElementEvents2
	{00020400-0000-0000-c000-000000000046}	IDispatch
	{1dc9ca50-06ef-11d2-8415-006008c3fbfc}	ITridentEventSink
	{d27cdb6d-ae6d-11cf-96b8-444553540000}	ShockwaveFlashObjects::_IShockwaveFlashEvents
*/
}