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

Function pythoncom_CoCreateInstance

com/win32com/src/PythonCOM.cpp:149–180  ·  view source on GitHub ↗

MODULE FUNCTIONS: pythoncom */ @pymethod |pythoncom|CoCreateInstance|Create a new instance of an OLE automation server.

Source from the content-addressed store, hash-verified

147/* MODULE FUNCTIONS: pythoncom */
148// @pymethod <o PyIUnknown>|pythoncom|CoCreateInstance|Create a new instance of an OLE automation server.
149static PyObject *pythoncom_CoCreateInstance(PyObject *self, PyObject *args)
150{
151 PyObject *obCLSID;
152 PyObject *obUnk;
153 DWORD dwClsContext;
154 PyObject *obiid;
155 CLSID clsid;
156 IUnknown *punk;
157 CLSID iid;
158 if (!PyArg_ParseTuple(args, "OOiO:CoCreateInstance",
159 &obCLSID, // @pyparm <o PyIID>|clsid||Class identifier (CLSID) of the object
160 &obUnk, // @pyparm <o PyIUnknown>|unkOuter||The outer unknown, or None
161 &dwClsContext,// @pyparm int|context||The create context for the object, combination of pythoncom.CLSCTX_* flags
162 &obiid)) // @pyparm <o PyIID>|iid||The IID required from the object
163 return NULL;
164 if (!PyWinObject_AsIID(obCLSID, &clsid))
165 return NULL;
166 if (!PyWinObject_AsIID(obiid, &iid))
167 return NULL;
168 if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&punk, TRUE))
169 return NULL;
170 // Make the call.
171 IUnknown *result = NULL;
172 PY_INTERFACE_PRECALL;
173 SCODE sc = CoCreateInstance(clsid, punk, dwClsContext, iid, (void **)&result);
174 if ( punk )
175 punk->Release();
176 PY_INTERFACE_POSTCALL;
177 if (FAILED(sc))
178 return PyCom_BuildPyException(sc);
179 return PyCom_PyObjectFromIUnknown(result, iid);
180}
181#ifdef _MSC_VER
182#pragma optimize ("", on)
183#endif // _MSC_VER

Callers 1

pythoncom_newFunction · 0.85

Calls 6

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

Tested by

no test coverage detected