示例#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();
}
// @pymethod <o PyIEnumConnections>|PyIConnectionPoint|EnumConnections|Creates an enumerator to iterate through the connections for the connection point
PyObject *PyIConnectionPoint::EnumConnections(PyObject *self, PyObject *args)
{
	if ( !PyArg_ParseTuple(args, ":EnumConnections") )
		return NULL;

	IConnectionPoint *pICP = GetI(self);
	if ( pICP == NULL )
		return NULL;

	IEnumConnections *p;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pICP->EnumConnections(&p);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return SetPythonCOMError(self,hr);

	return PyCom_PyObjectFromIUnknown(p, IID_IEnumConnections, FALSE);
}