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

Function pythoncom_CoCreateInstanceEx

com/win32com/src/PythonCOM.cpp:190–289  ·  view source on GitHub ↗

_MSC_VER @pymethod |pythoncom|CoCreateInstanceEx|Create a new instance of an OLE automation server possibly on a remote machine.

Source from the content-addressed store, hash-verified

188#endif // _MSC_VER
189// @pymethod <o PyIUnknown>|pythoncom|CoCreateInstanceEx|Create a new instance of an OLE automation server possibly on a remote machine.
190static PyObject *pythoncom_CoCreateInstanceEx(PyObject *self, PyObject *args)
191{
192 CHECK_PFN(CoCreateInstanceEx);
193 PyObject *obCLSID;
194 PyObject *obUnk;
195 PyObject *obCoServer;
196 DWORD dwClsContext;
197 PyObject *obrgiids;
198 CLSID clsid;
199 COSERVERINFO serverInfo = {0, NULL, NULL, 0};
200 COSERVERINFO *pServerInfo = NULL;
201 IID *iids = NULL;
202 MULTI_QI *mqi = NULL;
203 IUnknown *punk = NULL;
204 PyObject *result = NULL;
205 ULONG numIIDs = 0;
206 ULONG i;
207 if (!PyArg_ParseTuple(args, "OOiOO:CoCreateInstanceEx",
208 &obCLSID, // @pyparm <o PyIID>|clsid||Class identifier (CLSID) of the object
209 &obUnk, // @pyparm <o PyIUnknown>|unkOuter||The outer unknown, or None
210 &dwClsContext, // @pyparm int|context||The create context for the object, combination of pythoncom.CLSCTX_* flags
211 &obCoServer, // @pyparm (server, authino=None, reserved1=0,reserved2=0)|serverInfo||May be None, or describes the remote server to execute on.
212 &obrgiids)) // @pyparm [<o PyIID>, ...]|iids||A list of IIDs required from the object
213 return NULL;
214 if (!PyWinObject_AsIID(obCLSID, &clsid))
215 goto done;
216
217 if (obCoServer==Py_None)
218 pServerInfo = NULL;
219 else {
220 pServerInfo = &serverInfo;
221 PyObject *obName, *obAuth = Py_None;
222 if (!PyArg_ParseTuple(obCoServer, "O|Oii", &obName, &obAuth, &serverInfo.dwReserved1, &serverInfo.dwReserved2)) {
223 PyErr_Clear();
224 PyErr_SetString(PyExc_TypeError, "The SERVERINFO is not in the correct format");
225 goto done;
226 }
227 if (obAuth!=Py_None) {
228 PyErr_SetString(PyExc_TypeError, "authinfo in the SERVERINFO must be None");
229 goto done;
230 }
231 if (!PyWinObject_AsWCHAR(obName, &serverInfo.pwszName, FALSE))
232 goto done;
233 }
234 if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&punk, TRUE))
235 goto done;
236
237 if (!SeqToVector(obrgiids, &iids, &numIIDs, PyWinObject_AsIID))
238 goto done;
239 mqi = new MULTI_QI[numIIDs];
240 if (mqi==NULL) {
241 PyErr_SetString(PyExc_MemoryError, "Allocating MULTIQI array");
242 goto done;
243 }
244
245 for (i=0;i<numIIDs;i++) {
246 mqi[i].pIID = iids+i;
247 mqi[i].pItf = NULL;

Callers

nothing calls this directly

Calls 8

PyWinObject_AsIIDFunction · 0.85
SeqToVectorFunction · 0.85
FAILEDFunction · 0.85
PyCom_BuildPyExceptionFunction · 0.85
PyWinObject_AsWCHARFunction · 0.50
PyWinObject_FreeWCHARFunction · 0.50

Tested by

no test coverage detected