MCPcopy Create free account
hub / github.com/mhammond/pywin32 / pythoncom_CoRegisterClassObject

Function pythoncom_CoRegisterClassObject

com/win32com/src/PythonCOM.cpp:378–408  ·  view source on GitHub ↗

_MSC_VER @pymethod int|pythoncom|CoRegisterClassObject|Registers an EXE class object with OLE so other applications can connect to it.

Source from the content-addressed store, hash-verified

376#endif // _MSC_VER
377// @pymethod int|pythoncom|CoRegisterClassObject|Registers an EXE class object with OLE so other applications can connect to it.
378static PyObject *pythoncom_CoRegisterClassObject(PyObject *self, PyObject *args)
379{
380 DWORD reg;
381 DWORD context;
382 DWORD flags;
383 PyObject *obIID, *obFactory;
384 IID iid;
385
386 if (!PyArg_ParseTuple(args, "OOii:CoRegisterClassObject",
387 &obIID, // @pyparm <o PyIID>|iid||The IID of the object to register
388 &obFactory, // @pyparm <o PyIUnknown>|factory||The class factory object. It is the Python programmers responsibility to ensure this object remains alive until the class is unregistered.
389 &context, // @pyparm int|context||The create context for the server. Must be a combination of the CLSCTX_* flags.
390 &flags)) // @pyparm int|flags||Create flags.
391 return NULL;
392 // @comm The class factory object should be <o PyIClassFactory> object, but as per the COM documentation, only <o PyIUnknown> is checked.
393 if (!PyWinObject_AsIID(obIID, &iid))
394 return NULL;
395
396 IUnknown *pFactory;
397 if (!PyCom_InterfaceFromPyObject(obFactory, IID_IUnknown, (void **)&pFactory, /*BOOL bNoneOK=*/FALSE))
398 return NULL;
399
400 PY_INTERFACE_PRECALL;
401 HRESULT hr = CoRegisterClassObject(iid, pFactory, context, flags, &reg);
402 pFactory->Release();
403 PY_INTERFACE_POSTCALL;
404 if (FAILED(hr))
405 return PyCom_BuildPyException(hr);
406 // @rdesc The result is a handle which should be revoked using <om pythoncom.CoRevokeClassObject>
407 return PyInt_FromLong(reg);
408}
409// @pymethod |pythoncom|CoRevokeClassObject|Informs OLE that a class object, previously registered with the <om pythoncom.CoRegisterClassObject> method, is no longer available for use.
410static PyObject *pythoncom_CoRevokeClassObject(PyObject *self, PyObject *args)
411{

Callers

nothing calls this directly

Calls 5

PyWinObject_AsIIDFunction · 0.85
FAILEDFunction · 0.85
PyCom_BuildPyExceptionFunction · 0.85
ReleaseMethod · 0.45

Tested by

no test coverage detected