// @pymethod |PyIFileOperation|CopyItem|Adds a copy operation to the configuration PyObject *PyIFileOperation::CopyItem(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIShellItem>|Item||Item to be copied // @pyparm <o PyIShellItem>|DestinationFolder||Folder into which it will be copied // @pyparm str|CopyName|None|New name for the copied file, use None to keep original name // @pyparm <o PyGFileOperationProgressSink>|Sink|None|Progress sink for just this operation PyObject *obItem; PyObject *obDestinationFolder; PyObject *obCopyName = Py_None; PyObject *obSink = Py_None; IShellItem * pItem; IShellItem * pDestinationFolder; TmpWCHAR CopyName; IFileOperationProgressSink * pSink; if (!PyArg_ParseTuple(args, "OO|OO:CopyItem", &obItem, &obDestinationFolder, &obCopyName, &obSink)) return NULL; if (!PyWinObject_AsWCHAR(obCopyName, &CopyName, TRUE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obItem, IID_IShellItem, (void **)&pItem, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obDestinationFolder, IID_IShellItem, (void **)&pDestinationFolder, FALSE)) { PYCOM_RELEASE(pItem); return NULL; } if (!PyCom_InterfaceFromPyInstanceOrObject(obSink, IID_IFileOperationProgressSink, (void **)&pSink, TRUE)) { PYCOM_RELEASE(pItem); PYCOM_RELEASE(pDestinationFolder); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->CopyItem( pItem, pDestinationFolder, CopyName, pSink); pItem->Release(); pDestinationFolder->Release(); if (pSink) pSink->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIFileOperation|DeleteItem|Adds a delete operation to the configuration PyObject *PyIFileOperation::DeleteItem(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIShellItem>|Item||Description for psiItem // @pyparm <o PyGFileOperationProgressSink>|Sink|None|Progress sink for just this operation PyObject *obItem; PyObject *obSink = Py_None; IShellItem * pItem; IFileOperationProgressSink * pSink; if (!PyArg_ParseTuple(args, "O|O:DeleteItem", &obItem, &obSink)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obItem, IID_IShellItem, (void **)&pItem, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obSink, IID_IFileOperationProgressSink, (void **)&pSink, TRUE)) { PYCOM_RELEASE(pItem); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->DeleteItem(pItem, pSink); pItem->Release(); if (pSink) pSink->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIFileOperation|CopyItems|Adds multiple copy operations to the configuration PyObject *PyIFileOperation::CopyItems(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIUnknown>|Items||<o PyIShellItemArray>, <o PyIDataObject>, or <o PyIEnumShellItems> containing items to be copied // @pyparm <o PyIShellItem>|DestinationFolder||Folder into which they will be copied PyObject *obItems; PyObject *obDestinationFolder; IUnknown * pItems; IShellItem * pDestinationFolder; if ( !PyArg_ParseTuple(args, "OO:CopyItems", &obItems, &obDestinationFolder) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IUnknown, (void **)&pItems, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obDestinationFolder, IID_IShellItem, (void **)&pDestinationFolder, FALSE)) { PYCOM_RELEASE(pItems); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->CopyItems( pItems, pDestinationFolder ); pItems->Release(); pDestinationFolder->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }
// @pymethod str|PyITransferSource|GetDefaultDestinationName|Determines the name of an item as it would appear in a given folder PyObject *PyITransferSource::GetDefaultDestinationName(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Source||The item whose name is wanted // @pyparm <o PyIShellItem>|ParentDest||The destination folder PyObject *obpsiSource; PyObject *obpsiParentDest; IShellItem * psiSource; IShellItem * psiParentDest; LPWSTR pszDestinationName; if ( !PyArg_ParseTuple(args, "OO:GetDefaultDestinationName", &obpsiSource, &obpsiParentDest) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiParentDest, IID_IShellItem, (void **)&psiParentDest, FALSE)){ PYCOM_RELEASE(psiSource); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->GetDefaultDestinationName( psiSource, psiParentDest, &pszDestinationName ); psiSource->Release(); psiParentDest->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); PyObject *ret = PyWinObject_FromWCHAR(pszDestinationName); CoTaskMemFree(pszDestinationName); return ret; }
// @pymethod (int, <o PyIShellItem>|PyITransferSource|RecycleItem|Moves an item to the recycle bin PyObject *PyITransferSource::RecycleItem(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Source||The item to be recycled // @pyparm <o PyIShellItem>|ParentDest||Shell item representing the recycle bin TRANSFER_SOURCE_FLAGS flags; // @pyparm int|flags||Combination of shellcon.TSF_* flags PyObject *obpsiSource; PyObject *obpsiParentDest; IShellItem * psiSource; IShellItem * psiParentDest; IShellItem * ppsiNewDest; if ( !PyArg_ParseTuple(args, "OOi:RecycleItem", &obpsiSource, &obpsiParentDest, &flags) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiParentDest, IID_IShellItem, (void **)&psiParentDest, FALSE)){ PYCOM_RELEASE(psiSource); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->RecycleItem( psiSource, psiParentDest, flags, &ppsiNewDest ); psiSource->Release(); psiParentDest->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); return Py_BuildValue("lO", hr, PyCom_PyObjectFromIUnknown(ppsiNewDest, IID_IShellItem, FALSE)); }
//////////////////////////////////////////////////////////////////////// // // Client Side Errors - translate a COM failure to a Python exception // //////////////////////////////////////////////////////////////////////// PyObject *PyCom_BuildPyException(HRESULT errorhr, IUnknown *pUnk /* = NULL */, REFIID iid /* = IID_NULL */) { PyObject *obEI = NULL; TCHAR scodeStringBuf[512]; GetScodeString(errorhr, scodeStringBuf, sizeof(scodeStringBuf)/sizeof(scodeStringBuf[0])); #ifndef MS_WINCE // WINCE doesnt appear to have GetErrorInfo() - compiled, but doesnt link! if (pUnk != NULL) { assert(iid != IID_NULL); // If you pass an IUnknown, you should pass the specific IID. // See if it supports error info. ISupportErrorInfo *pSEI; HRESULT hr; Py_BEGIN_ALLOW_THREADS hr = pUnk->QueryInterface(IID_ISupportErrorInfo, (void **)&pSEI); if (SUCCEEDED(hr)) { hr = pSEI->InterfaceSupportsErrorInfo(iid); pSEI->Release(); // Finished with this object } Py_END_ALLOW_THREADS if (SUCCEEDED(hr)) { IErrorInfo *pEI; Py_BEGIN_ALLOW_THREADS hr=GetErrorInfo(0, &pEI); Py_END_ALLOW_THREADS if (hr==S_OK) { obEI = PyCom_PyObjectFromIErrorInfo(pEI, errorhr); PYCOM_RELEASE(pEI); } } }
// @pymethod object|PyIEnumDebugStackFrames|Next|Retrieves a specified number of items in the enumeration sequence. PyObject *PyIEnumDebugStackFrames::Next(PyObject *self, PyObject *args) { long celt = 1; // @pyparm int|num|1|Number of items to retrieve. if ( !PyArg_ParseTuple(args, "|l:Next", &celt) ) return NULL; IEnumDebugStackFrames *pIEDebugStackFrames = GetI(self); if ( pIEDebugStackFrames == NULL ) return NULL; DebugStackFrameDescriptor *rgVar = new DebugStackFrameDescriptor [celt]; if ( rgVar == NULL ) { PyErr_SetString(PyExc_MemoryError, "allocating result IDebugStackFrameDescriptor"); return NULL; } int i; /* for ( i = celt; i--; ) // *** possibly init each structure element??? */ ULONG celtFetched = 0; PY_INTERFACE_PRECALL; HRESULT hr = pIEDebugStackFrames->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) ) { delete [] rgVar; return SetPythonCOMError(self,hr); } PyObject *result = PyTuple_New(celtFetched); if ( result != NULL ) { for ( i = celtFetched; i--; ) { // Make a result tuple. PyObject *obFrame = PyCom_PyObjectFromIUnknown(rgVar[i].pdsf, IID_IDebugStackFrame, FALSE); rgVar[i].pdsf = NULL; if ( obFrame == NULL) { Py_DECREF(result); result = NULL; break; } PyObject *obUnkFinal = PyCom_PyObjectFromIUnknown(rgVar[i].punkFinal, IID_IUnknown, TRUE); PyTuple_SET_ITEM(result, i, Py_BuildValue("OiiiO", obFrame, rgVar[i].dwMin, rgVar[i].dwLim, rgVar[i].fFinal, obUnkFinal)); Py_DECREF(obFrame); Py_XDECREF(obUnkFinal); } } for ( i = celtFetched; i--; ) PYCOM_RELEASE(rgVar[i].pdsf); delete [] rgVar; return result; }
// @pymethod object|PyIEnumRemoteDebugApplications|Next|Retrieves a specified number of items in the enumeration sequence. PyObject *PyIEnumRemoteDebugApplications::Next(PyObject *self, PyObject *args) { long celt = 1; // @pyparm int|num|1|Number of items to retrieve. if ( !PyArg_ParseTuple(args, "|l:Next", &celt) ) return NULL; IEnumRemoteDebugApplications *pIERemoteDebugApplications = GetI(self); if ( pIERemoteDebugApplications == NULL ) return NULL; IRemoteDebugApplication **rgVar = new IRemoteDebugApplication *[celt]; if ( rgVar == NULL ) { PyErr_SetString(PyExc_MemoryError, "allocating result IRemoteDebugApplications"); return NULL; } int i; /* for ( i = celt; i--; ) // *** possibly init each structure element??? */ ULONG celtFetched = 0; PY_INTERFACE_PRECALL; HRESULT hr = pIERemoteDebugApplications->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) ) { delete [] rgVar; return SetPythonCOMError(self,hr); } PyObject *result = PyTuple_New(celtFetched); if ( result != NULL ) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IRemoteDebugApplication, FALSE); rgVar[i] = NULL; if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; } PyTuple_SET_ITEM(result, i, ob); } } for ( i = celtFetched; i--; ) PYCOM_RELEASE(rgVar[i]); delete [] rgVar; return result; }
// @pymethod <o PyIMoniker>|PyIEnumMoniker|Next|Retrieves a specified number of items in the enumeration sequence. PyObject *PyIEnumMoniker::Next(PyObject *self, PyObject *args) { long celt = 1; // @pyparm int|num|1|Number of items to retrieve. if ( !PyArg_ParseTuple(args, "|l:Next", &celt) ) return NULL; IEnumMoniker *pMy = GetI(self); if (pMy==NULL) return NULL; IMoniker **rgVar = new IMoniker *[celt]; if ( rgVar == NULL ) { PyErr_SetString(PyExc_MemoryError, "allocating result IMoniker *s"); return NULL; } int i; ULONG celtFetched; PY_INTERFACE_PRECALL; HRESULT hr = pMy->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) { delete [] rgVar; return PyCom_BuildPyException(hr); } PyObject *result = PyTuple_New(celtFetched); if (result) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IMoniker, FALSE); rgVar[i] = NULL; if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; } PyTuple_SET_ITEM(result, i, ob); } } for ( i = celtFetched; i--; ) PYCOM_RELEASE(rgVar[i]); delete [] rgVar; return result; // @rdesc The result is a tuple of <o PyIID> objects, // one for each element returned. Note that if zero elements are returned, it is not considered // an error condition - an empty tuple is simply returned. }
// @pymethod <o PyIUnknown>|PyIMoniker|BindToStorage|Retrieves an interface object to the storage that contains the object identified by the moniker. PyObject *PyIMoniker::BindToStorage(PyObject *self, PyObject *args) { // @pyparm <o PyIBindCtx>|bindCtx||bind context object to be used. // @pyparm <o PyIMoniker>|moniker||If the moniker is part of a composite moniker, otherwise None // @pyparm <o IID>|iidResult||IID of the result object. PyObject *obBindCtx; PyObject *obMoniker; PyObject *obIID; if (!PyArg_ParseTuple(args, "OOO:BindToStorage", &obBindCtx, &obMoniker, &obIID)) return NULL; IMoniker *pMy = GetI(self); if (pMy==NULL) return NULL; IBindCtx *pBindCtx; if (!PyCom_InterfaceFromPyInstanceOrObject(obBindCtx, IID_IBindCtx, (void **)&pBindCtx, FALSE)) return NULL; IMoniker *pMonLeft = NULL; if (obMoniker!=Py_None) { if (!PyCom_InterfaceFromPyInstanceOrObject(obMoniker, IID_IMoniker, (void **)&pMonLeft, FALSE)) { PYCOM_RELEASE(pBindCtx); return NULL; } } IID iid; if (!PyWinObject_AsIID(obIID, &iid)) { PY_INTERFACE_PRECALL; pBindCtx->Release(); if (pMonLeft) pMonLeft->Release(); PY_INTERFACE_POSTCALL; return NULL; } void *pResult = NULL; PY_INTERFACE_PRECALL; HRESULT hr = pMy->BindToStorage(pBindCtx, pMonLeft, iid, &pResult ); pBindCtx->Release(); if (pMonLeft) pMonLeft->Release(); PY_INTERFACE_POSTCALL; if (S_OK!=hr) // S_OK only acceptable return PyCom_BuildPyException(hr, pMy, IID_IMoniker); return PyCom_PyObjectFromIUnknown((IUnknown *)pResult, iid, FALSE ); }
// @pymethod |pythoncom|RegisterTypeLib|Adds information about a type library to the system registry. PyObject *pythoncom_registertypelib(PyObject *self, PyObject *args) { PyObject *obTypeLib, *obPath, *obHelpDir = Py_None; // @pyparm <o PyITypeLib>|typelib||The type library being registered. // @pyparm string|fullPath||Fully qualified path specification for the type library being registered // @pyparm string|helpDir|None|Directory in which the Help file for the library being registered can be found. Can be None. // @pyparm int|lcid|LOCALE_USER_DEFAULT|The locale ID to use. if (!PyArg_ParseTuple(args, "OO|O:RegisterTypeLib", &obTypeLib, &obPath, &obHelpDir)) return NULL; PyObject *result = NULL; BSTR bstrPath = NULL; BSTR bstrHelpDir = NULL; ITypeLib *pLib = NULL; SCODE sc; if (!PyWinObject_AsBstr(obPath, &bstrPath, FALSE)) goto done; if (!PyWinObject_AsBstr(obHelpDir, &bstrHelpDir, TRUE)) goto done; if (!PyCom_InterfaceFromPyInstanceOrObject(obTypeLib, IID_ITypeLib, (void **)&pLib, FALSE)) goto done; { // scope to avoid warning about var decl and goto. PY_INTERFACE_PRECALL; sc = RegisterTypeLib(pLib, bstrPath, bstrHelpDir); PY_INTERFACE_POSTCALL; } if (FAILED(sc)) return PyCom_BuildPyException(sc); result = Py_None; Py_INCREF(result); done: if (bstrPath) SysFreeString(bstrPath); if (bstrHelpDir) SysFreeString(bstrHelpDir); PYCOM_RELEASE(pLib); return result; // @comm This function can be used during application initialization to register the application's type // library correctly. When RegisterTypeLib is called to register a type library, // both the minor and major version numbers are registered in hexadecimal. // <nl> In addition to filling in a complete registry entry under the type library key, // RegisterTypeLib adds entries for each of the dispinterfaces and Automation-compatible // interfaces, including dual interfaces. This information is required to create // instances of these interfaces. Coclasses are not registered (that is, // RegisterTypeLib does not write any values to the CLSID key of the coclass). }
// @pymethod |PyIFileOperation|NewItem|Creates a new file as part of the operation PyObject *PyIFileOperation::NewItem(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIShellItem>|DestinationFolder||Folder in which to create the file // @pyparm int|FileAttributes||Combination of win32con.FILE_ATTRIBUTE_* flags // @pyparm str|Name||Name of the new file // @pyparm str|TemplateName|None|Template file used to initialize the new file // @pyparm <o PyGFileOperationProgressSink>|Sink|None|Progress sink for just this operation PyObject *obDestinationFolder; PyObject *obName; PyObject *obTemplateName = Py_None; PyObject *obSink = Py_None; IShellItem * pDestinationFolder; DWORD FileAttributes; TmpWCHAR Name; TmpWCHAR TemplateName; IFileOperationProgressSink * pSink; if (!PyArg_ParseTuple(args, "OkO|OO:NewItem", &obDestinationFolder, &FileAttributes, &obName, &obTemplateName, &obSink)) return NULL; if (!PyWinObject_AsWCHAR(obName, &Name, FALSE)) return NULL; if (!PyWinObject_AsWCHAR(obTemplateName, &TemplateName, TRUE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obDestinationFolder, IID_IShellItem, (void **)&pDestinationFolder, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obSink, IID_IFileOperationProgressSink, (void **)&pSink, TRUE)) { PYCOM_RELEASE(pDestinationFolder); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->NewItem(pDestinationFolder, FileAttributes, Name, TemplateName, pSink); pDestinationFolder->Release(); if (pSink) pSink->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }
// @pymethod (int, <o PyIShellItem>|PyITransferSource|LinkItem|Not implemented, according to MSDN PyObject *PyITransferSource::LinkItem(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Source||Description for psiSource // @pyparm <o PyIShellItem>|ParentDest||Description for psiParentDest // @pyparm str|NewName||Description for NewName TRANSFER_SOURCE_FLAGS flags; // @pyparm int|flags||Combination of shellcon.TSF_* flags PyObject *obpsiSource; PyObject *obpsiParentDest; PyObject *obNewName; IShellItem * psiSource; IShellItem * psiParentDest; TmpWCHAR NewName; IShellItem * ppsiNewDest; if ( !PyArg_ParseTuple(args, "OOOi:LinkItem", &obpsiSource, &obpsiParentDest, &obNewName, &flags) ) return NULL; if (!PyWinObject_AsWCHAR(obNewName, &NewName)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiParentDest, IID_IShellItem, (void **)&psiParentDest, FALSE)){ PYCOM_RELEASE(psiSource); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->LinkItem( psiSource, psiParentDest, NewName, flags, &ppsiNewDest ); psiSource->Release(); psiParentDest->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); return Py_BuildValue("lN", hr, PyCom_PyObjectFromIUnknown(ppsiNewDest, IID_IShellItem, FALSE)); }
// @pymethod (int, <o PyIShellItem>|PyITransferSource|MoveItem|Moves a shell item into another folder // @rdesc Returns the HRESULT from the operation and the new shell item, which may be None // when the code in one of the informational COPYENGINE_S_* values. See MSDN for descriptions // of expected actions for specific error codes. PyObject *PyITransferSource::MoveItem(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Item||Item to be moved // @pyparm <o PyIShellItem>|ParentDst||The folder into which it will be moved // @pyparm <o unicode>|NameDst||New name for item after move, None to keep same name TRANSFER_SOURCE_FLAGS flags; // @pyparm int|flags||Combination of shellcon.TSF_* flags PyObject *obpsi; PyObject *obpsiParentDst; PyObject *obNameDst; IShellItem * psi; IShellItem * psiParentDst; TmpWCHAR NameDst; IShellItem * ppsiNew; if ( !PyArg_ParseTuple(args, "OOOi:MoveItem", &obpsi, &obpsiParentDst, &obNameDst, &flags) ) return NULL; if (!PyWinObject_AsWCHAR(obNameDst, &NameDst, TRUE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsi, IID_IShellItem, (void **)&psi, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiParentDst, IID_IShellItem, (void **)&psiParentDst, FALSE)){ PYCOM_RELEASE(psi); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->MoveItem( psi, psiParentDst, NameDst, flags, &ppsiNew ); psi->Release(); psiParentDst->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); return Py_BuildValue("lN", hr, PyCom_PyObjectFromIUnknown(ppsiNew, IID_IShellItem, FALSE)); }
// @pymethod string|PyIMoniker|GetDisplayName|Gets the display name , which is a user-readable representation of this moniker. PyObject *PyIMoniker::GetDisplayName(PyObject *self, PyObject *args) { // @pyparm <o PyIBindCtx>|bindCtx||bind context object to be used. // @pyparm <o PyIMoniker>|moniker||If the moniker is part of a composite moniker, otherwise None PyObject *obBindCtx; PyObject *obMoniker; if (!PyArg_ParseTuple(args, "OO:GetDisplayName", &obBindCtx, &obMoniker)) return NULL; IMoniker *pMy = GetI(self); if (pMy==NULL) return NULL; IBindCtx *pBindCtx; if (!PyCom_InterfaceFromPyInstanceOrObject(obBindCtx, IID_IBindCtx, (void **)&pBindCtx, FALSE)) return NULL; IMoniker *pMonLeft = NULL; if (obMoniker!=Py_None) { if (!PyCom_InterfaceFromPyInstanceOrObject(obMoniker, IID_IMoniker, (void **)&pMonLeft, FALSE)) { PYCOM_RELEASE(pBindCtx); return NULL; } } LPOLESTR result; PY_INTERFACE_PRECALL; HRESULT hr = pMy->GetDisplayName(pBindCtx, pMonLeft, &result ); pBindCtx->Release(); if (pMonLeft) pMonLeft->Release(); PY_INTERFACE_POSTCALL; if (S_OK!=hr) // S_OK only acceptable return PyCom_BuildPyException(hr, pMy, IID_IMoniker); PyObject *obResult = PyWinObject_FromWCHAR(result); CoTaskMemFree(result); return obResult; }
// @pymethod |PyIFileOperation|RenameItem|Adds a rename to the operation sequence PyObject *PyIFileOperation::RenameItem(PyObject *self, PyObject *args) { IFileOperation *pIFO = GetI(self); if ( pIFO == NULL ) return NULL; // @pyparm <o PyIShellItem>|Item||The item to be renamed // @pyparm str|NewName||The new name // @pyparm <o PyGFileOperationProgressSink>|Sink|None|Progress sink for this operation only. PyObject *obItem, *obNewName, *obSink = Py_None; IShellItem * pItem; TmpWCHAR NewName; IFileOperationProgressSink * pSink; if ( !PyArg_ParseTuple(args, "OO|O:RenameItem", &obItem, &obNewName, &obSink)) return NULL; if (!PyWinObject_AsWCHAR(obNewName, &NewName, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obItem, IID_IShellItem, (void **)&pItem, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obSink, IID_IFileOperationProgressSink, (void **)&pSink, TRUE)) { PYCOM_RELEASE(pItem); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIFO->RenameItem(pItem, NewName, pSink); pItem->Release(); if (pSink) pSink->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIFO, IID_IFileOperation ); Py_INCREF(Py_None); return Py_None; }