[pywin32-checkins] pywin32/com/win32com/src PythonCOM.cpp,1.36,1.37
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-10-20 22:36:15
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11660 Modified Files: PythonCOM.cpp Log Message: Add CoGetObject and CreateItemMoniker Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** PythonCOM.cpp 31 May 2005 12:36:02 -0000 1.36 --- PythonCOM.cpp 20 Oct 2005 22:36:07 -0000 1.37 *************** *** 883,886 **** --- 883,918 ---- } + // @pymethod <o PyIMoniker>|pythoncom|CreateItemMoniker|Creates an item moniker + // that identifies an object within a containing object (typically a compound document). + static PyObject *pythoncom_CreateItemMoniker(PyObject *self, PyObject *args) + { + PyObject *obDelim, *obItem; + // @pyparm string|delim||String containing the delimiter (typically "!") used to separate this item's display name from the display name of its containing object. + // @pyparm string|item||String indicating the containing object's name for the object being identified. + if ( !PyArg_ParseTuple(args, "OO:CreateItemMoniker", &obDelim, &obItem) ) + return NULL; + + BSTR bstrDelim, bstrItem; + if (!PyWinObject_AsBstr(obDelim, &bstrDelim, TRUE)) + return NULL; + + if (!PyWinObject_AsBstr(obItem, &bstrItem, FALSE)) { + PyWinObject_FreeBstr(bstrDelim); + return NULL; + } + + IMoniker *pmk; + PY_INTERFACE_PRECALL; + HRESULT hr = CreateItemMoniker(bstrDelim, bstrItem, &pmk); + PY_INTERFACE_POSTCALL; + PyWinObject_FreeBstr(bstrDelim); + PyWinObject_FreeBstr(bstrItem); + + if ( FAILED(hr) ) + return PyCom_BuildPyException(hr); + + return PyCom_PyObjectFromIUnknown(pmk, IID_IMoniker, FALSE); + } + // @pymethod <o PyIID>|pythoncom|GetClassFile|Supplies the CLSID associated with the given filename. static PyObject *pythoncom_GetClassFile(PyObject *self, PyObject *args) *************** *** 1121,1124 **** --- 1153,1192 ---- #endif // MS_WINCE + // @pymethod <o PyIUnknown>|pythoncom|CoGetObject|Converts a display name into a moniker that identifies the object named, and then binds to the object identified by the moniker. + static PyObject *pythoncom_CoGetObject(PyObject *self, PyObject*args) + { + PyObject *obName; + PyObject *obBindOpts = Py_None; + PyObject *obIID = Py_None; + if (!PyArg_ParseTuple(args, "O|OO:CoGetObject", + &obName, // @pyparm string|name|| + &obBindOpts, // @pyparm None|bindOpts||Must be None + &obIID )) // @pyparm <o PyIID>|iid||The IID if the interface to unmarshal. + return NULL; + + if (obBindOpts != Py_None) + return PyErr_Format(PyExc_ValueError, "BindOptions must be None"); + + IID iid; + if (obIID == Py_None) + iid = IID_IUnknown; + else { + if (!PyWinObject_AsIID(obIID, &iid)) + return NULL; + } + + PyWin_AutoFreeBstr name; + if (!PyWinObject_AsAutoFreeBstr(obName, &name)) + return NULL; + + IUnknown *pUnk; + PY_INTERFACE_PRECALL; + HRESULT hr = CoGetObject(name, NULL, iid, (void **)&pUnk); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + return PyCom_PyObjectFromIUnknown(pUnk, iid, /*BOOL bAddRef*/ FALSE); + } + // @pymethod |pythoncom|OleLoad|Loads into memory an object nested within a specified storage object. static PyObject *pythoncom_OleLoad(PyObject *self, PyObject* args) *************** *** 1580,1583 **** --- 1648,1652 ---- { "CoMarshalInterThreadInterfaceInStream", pythoncom_CoMarshalInterThreadInterfaceInStream, 1}, // @pymeth CoMarshalInterThreadInterfaceInStream|Marshals an interface pointer from one thread to another thread in the same process. #endif // MS_WINCE + { "CoGetObject", pythoncom_CoGetObject, 1}, // @pymeth CoGetObject|Converts a display name into a moniker that identifies the object named, and then binds to the object identified by the moniker. { "CoUninitialize", pythoncom_CoUninitialize, 1 }, // @pymeth CoUninitialize|Uninitialize the COM libraries. #ifndef MS_WINCE *************** *** 1592,1595 **** --- 1661,1665 ---- { "CreateBindCtx", pythoncom_CreateBindCtx, 1 }, // @pymeth CreateBindCtx|Obtains a <o PyIBindCtx> object. { "CreateFileMoniker", pythoncom_CreateFileMoniker, 1 }, // @pymeth CreateFileMoniker|Creates a file moniker given a file name. + { "CreateItemMoniker", pythoncom_CreateItemMoniker, 1 }, // @pymeth CreateItemMoniker|Creates an item moniker that identifies an object within a containing object (typically a compound document). { "CreatePointerMoniker", pythoncom_CreatePointerMoniker, 1 }, // @pymeth CreatePointerMoniker|Creates a pointer moniker based on a pointer to an object. { "CreateTypeLib", pythoncom_CreateTypeLib, 1}, // @pymeth CreateTypeLib|Provides access to a new object instance that supports the ICreateTypeLib interface. *************** *** 1909,1912 **** --- 1979,1985 ---- ADD_CONSTANT(REGCLS_SUSPENDED); + // ROT + ADD_CONSTANT(ROTFLAGS_REGISTRATIONKEEPSALIVE); + ADD_CONSTANT(ROTFLAGS_ALLOWANYCLIENT); // RPC ADD_CONSTANT(RPC_C_AUTHN_LEVEL_NONE); // RPC_C_AUTHN_LEVEL_NONE|Performs no authentication. |