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

Function pythoncom_new

com/win32com/src/PythonCOM.cpp:563–581  ·  view source on GitHub ↗

@pymethod |pythoncom|new|Create a new instance of an OLE automation server.

Source from the content-addressed store, hash-verified

561
562// @pymethod <o PyIDispatch>|pythoncom|new|Create a new instance of an OLE automation server.
563static PyObject *pythoncom_new(PyObject *self, PyObject *args)
564{
565 PyErr_Clear();
566 PyObject *progid;
567 // @pyparm CLSID|cls||An identifier for the program. Usually "program.item"
568 if (!PyArg_ParseTuple(args, "O", &progid))
569 return NULL;
570
571 // @comm This is just a wrapper for the CoCreateInstance method.
572 // Specifically, this call is identical to:
573 // <nl>pythoncom.CoCreateInstance(cls, None, pythoncom.CLSCTX_SERVER, pythoncom.IID_IDispatch)
574 int clsctx = PyCom_HasDCom() ? CLSCTX_SERVER : CLSCTX_INPROC_SERVER| CLSCTX_LOCAL_SERVER;
575 PyObject *obIID = PyWinObject_FromIID(IID_IDispatch);
576 PyObject *newArgs = Py_BuildValue("OOiO", progid, Py_None, clsctx, obIID);
577 Py_DECREF(obIID);
578 PyObject *rc = pythoncom_CoCreateInstance(self, newArgs);
579 Py_DECREF(newArgs);
580 return rc;
581}
582
583#ifndef MS_WINCE
584// @pymethod <o PyIID>|pythoncom|CreateGuid|Creates a new, unique GUIID.

Callers

nothing calls this directly

Calls 3

PyCom_HasDComFunction · 0.85
PyWinObject_FromIIDFunction · 0.85

Tested by

no test coverage detected