[pywin32-checkins] pywin32/com/win32com/src/extensions PyIRunningObjectTable.cpp,1.4,1.5
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-10-20 22:36:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11717/extensions Modified Files: PyIRunningObjectTable.cpp Log Message: Add IRunningObjectTable::Register and Revoke. Index: PyIRunningObjectTable.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIRunningObjectTable.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIRunningObjectTable.cpp 2 Nov 2003 09:57:44 -0000 1.4 --- PyIRunningObjectTable.cpp 20 Oct 2005 22:36:35 -0000 1.5 *************** *** 92,98 **** --- 92,151 ---- } + // @pymethod int|PyIRunningObjectTable|Register|Registers an object and its identifying moniker in the Running Object Table (ROT). + PyObject *PyIRunningObjectTable::Register(PyObject *self, PyObject *args) + { + PyObject *obUnk, *obMk; + int flags; + if (!PyArg_ParseTuple(args, "iOO:Register", &flags, &obUnk, &obMk)) + return NULL; + + IRunningObjectTable *pMy = GetI(self); + if (pMy==NULL) return NULL; + + IUnknown *pUnknown; + if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&pUnknown, FALSE)) + return NULL; + + IMoniker *pMoniker; + if (!PyCom_InterfaceFromPyInstanceOrObject(obMk, IID_IMoniker, (void **)&pMoniker, FALSE)) { + pUnknown->Release(); + return NULL; + } + DWORD tok; + PY_INTERFACE_PRECALL; + HRESULT hr = pMy->Register(flags, pUnknown, pMoniker, &tok); + pMoniker->Release(); + pUnknown->Release(); + PY_INTERFACE_POSTCALL; + if (S_OK!=hr) // S_OK only acceptable + return PyCom_BuildPyException(hr, pMy, IID_IRunningObjectTable); + return PyInt_FromLong(tok); + } + + // @pymethod int|PyIRunningObjectTable|Revoke|Removes from the Running Object Table + // (ROT) an entry that was previously registered by a call to <om PyIRunningObjectTable.Register>. + PyObject *PyIRunningObjectTable::Revoke(PyObject *self, PyObject *args) + { + int tok; + if (!PyArg_ParseTuple(args, "i:Revoke", &tok)) + return NULL; + + IRunningObjectTable *pMy = GetI(self); + if (pMy==NULL) return NULL; + + PY_INTERFACE_PRECALL; + HRESULT hr = pMy->Revoke(tok); + PY_INTERFACE_POSTCALL; + if (S_OK!=hr) // S_OK only acceptable + return PyCom_BuildPyException(hr, pMy, IID_IRunningObjectTable); + Py_INCREF(Py_None); + return Py_None; + } + // @object PyIRunningObjectTable|A Python interface to IRunningObjectTable static struct PyMethodDef PyIRunningObjectTable_methods[] = { + {"Register", PyIRunningObjectTable::Register, 1}, // @pymeth Register|Registers an object in the ROT + {"Revoke", PyIRunningObjectTable::Revoke, 1}, // @pymeth Revoke|Revokes a previously registered object {"IsRunning", PyIRunningObjectTable::IsRunning, 1}, // @pymeth IsRunning|Checks whether an object is running. {"GetObject", PyIRunningObjectTable::GetObject, 1}, // @pymeth GetObject|Checks whether an object is running. |