// @pymethod |PyIPersistPropertyBag|Load|Called by the container to load the control's properties.
PyObject *PyIPersistPropertyBag::Load(PyObject *self, PyObject *args)
{
	PyObject *obBag; // @pyparm <o PyIPropertyBag>|bag||the caller's property bag.
	PyObject *obLog = NULL; // @pyparm <o PyIErrorLog>|log|None|the caller's error log, or None
	if ( !PyArg_ParseTuple(args, "O|O:Load", &obBag, &obLog) )
		return NULL;

	IPersistPropertyBag *pIPPB = GetI(self);
	if ( pIPPB == NULL )
		return NULL;

	IPropertyBag *pIPB;
	if ( !PyCom_InterfaceFromPyObject(obBag, IID_IPropertyBag, (LPVOID*)&pIPB, FALSE) )
		return NULL;

	IErrorLog *pIEL = NULL;
	if ( obLog != NULL && obLog != Py_None &&
		 !PyCom_InterfaceFromPyObject(obLog, IID_IErrorLog, (LPVOID*)&pIEL, FALSE) )
	{
		pIPB->Release();
		return NULL;
	}

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIPPB->Load(pIPB, pIEL);
	pIPB->Release();
	pIEL->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPPB, IID_IPersistPropertyBag);

	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod <o PyIShellItem>|PyIShellLibrary|Save|Saves the library to a specific location
// @rdesc Returns a shell item for the saved file.
PyObject *PyIShellLibrary::Save(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	IShellItem *FolderToSaveIn, *SavedTo;
	PyObject *obFolderToSaveIn;
	TmpWCHAR LibraryName;
	PyObject *obLibraryName;
	LIBRARYSAVEFLAGS Flags;
	// @pyparm <o PyIShellItem>|FolderToSaveIn||The destination folder, use None to save in current user's Libraries folder 
	// @pyparm str|LibraryName||Filename for the new library, without file extension
	// @pyparm int|Flags||Determines behaviour if file already exists, shellcon.LSF_*
	if ( !PyArg_ParseTuple(args, "OOi:Save", &obFolderToSaveIn, &obLibraryName, &Flags))
		return NULL;
	if (!PyWinObject_AsWCHAR(obLibraryName, &LibraryName, FALSE))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obFolderToSaveIn, IID_IShellItem, (void **)&FolderToSaveIn, TRUE))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->Save(FolderToSaveIn, LibraryName, Flags, &SavedTo);
	if (FolderToSaveIn)
		FolderToSaveIn->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	return PyCom_PyObjectFromIUnknown(SavedTo, IID_IShellItem, FALSE);
}
// @pymethod |pythoncom|WriteClassStg|Writes a CLSID to a storage object
PyObject *pythoncom_WriteClassStg(PyObject *self, PyObject *args)
{
	PyObject *obStg;
	PyObject *obCLSID;
	if (!PyArg_ParseTuple(args, "OO:WriteClassStg",
					   &obStg, // @pyparm <o PyIStorage>|storage||Storage object into which CLSID will be written.
					   &obCLSID)) // @pyparm <o PyIID>|iid||The IID to write
		return NULL;

	CLSID clsid;
	if (!PyWinObject_AsIID(obCLSID, &clsid))
		return NULL;

	IStorage *pStorage;
	if (!PyCom_InterfaceFromPyObject(obStg, IID_IStorage, (void **)&pStorage, FALSE))
		return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = WriteClassStg(pStorage, clsid);
	pStorage->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod |PyIShellLibrary|LoadLibraryFromItem|Loads an existing library file
PyObject *PyIShellLibrary::LoadLibraryFromItem(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	IShellItem *Library;
	PyObject *obLibrary;
	DWORD Mode;
	// @pyparm <o PyIShellItem>|Library||Shell item interface representing the library file
	// @pyparm int|Mode||Access mode, combination of storagecon.STGM_* flags
	if ( !PyArg_ParseTuple(args, "Ok:LoadLibraryFromItem", &obLibrary, &Mode) )
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obLibrary, IID_IShellItem, (void **)&Library, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->LoadLibraryFromItem(Library, Mode);
	Library->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod <o PyIShellItem>|PyIShellLibrary|ResolveFolder|Attempts to locate a folder that has been moved or renamed
PyObject *PyIShellLibrary::ResolveFolder(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	IShellItem *FolderToResolve;
	PyObject *obFolderToResolve;
	DWORD Timeout;
	IID riid = IID_IShellItem;
	// @pyparm <o PyIShellItem>|FolderToResolve||Library item whose location has changed
	// @pyparm int|Timeout||Max search time, specified in milliseconds
	// @pyparm <o PyIID>|riid|IID_IShellItem|The interface to return
	if (!PyArg_ParseTuple(args, "Ok|O&:ResolveFolder",
		&obFolderToResolve, &Timeout,
		PyWinObject_AsIID, &riid))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obFolderToResolve, IID_IShellItem, (void **)&FolderToResolve, FALSE))
		return NULL;

	void *pv;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->ResolveFolder(FolderToResolve, Timeout, riid, &pv );
	FolderToResolve->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE);
}
STDMETHODIMP PyGDocHostUIHandler::GetDropTarget(
		/* [in] */ IDropTarget * pDropTarget,
		/* [out] */ IDropTarget ** ppDropTarget)
{
	PY_GATEWAY_METHOD;
	try {
		*ppDropTarget = NULL;
		PyObject *obpdropTargetIn = NULL;
		obpdropTargetIn = PyCom_PyObjectFromIUnknown(pDropTarget, IID_IUnknown, TRUE);
		PyObject *obpResult = NULL;
		HRESULT hr=InvokeViaPolicy("GetDropTarget", &obpResult, "O", obpdropTargetIn);
		Py_XDECREF(obpdropTargetIn);

		hr = S_FALSE;
		if (obpResult != NULL) {
			if (PyCom_InterfaceFromPyObject(obpResult, IID_IDropTarget, (void** )ppDropTarget, TRUE)) {
				hr = S_OK;
			}
			Py_XDECREF(obpResult);
		}
		return hr;
	} catch(...) {
		*ppDropTarget = NULL;
		return S_FALSE;
	}
}
// @pymethod |pythoncom|WriteClassStm|Writes a CLSID to a stream.
PyObject *pythoncom_WriteClassStm(PyObject *self, PyObject *args)
{
	PyObject *obStm;
	PyObject *obCLSID;
	if (!PyArg_ParseTuple(args, "OO:WriteClassStm",
		&obStm,		// @pyparm <o PyIStream>|Stm||An IStream interface
		&obCLSID))	// @pyparm <o PyIID>|clsid||The IID to write
		return NULL;

	CLSID clsid;
	if (!PyWinObject_AsIID(obCLSID, &clsid))
		return NULL;

	IStream *pStm;
	if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE))
		return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = WriteClassStm(pStm, clsid);
	pStm->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	Py_INCREF(Py_None);
	return Py_None;
}
Example #8
0
static PyObject *pyBindIFilterFromStream(PyObject *self, PyObject *args)
{
	HRESULT hr;
	IUnknown *pOb = NULL;
	PyObject *obStg;
	
	PyObject *ret;
	long lres = 0;
	if (!PyArg_ParseTuple(args, "O:BindIFilterFromStream", &obStg)) 
		return NULL;

	IStream *pstm;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyObject(obStg, IID_IStream, (void **)&pstm, FALSE /* bNoneOK */))
		bPythonIsHappy = FALSE;

	if (!bPythonIsHappy)
		return NULL;

	Py_BEGIN_ALLOW_THREADS;
	hr = BindIFilterFromStream( pstm , NULL , (void**)&pOb ); 
	pstm->Release();
	Py_END_ALLOW_THREADS;
	if (FAILED(hr))
		ret = OleSetOleError(hr);
	else
		ret = PyCom_PyObjectFromIUnknown(pOb, IID_IFilter, FALSE);
	return ret;
}
// @pymethod |PyIPersistPropertyBag|Save|Called by the container to save the object's properties.
PyObject *PyIPersistPropertyBag::Save(PyObject *self, PyObject *args)
{
	PyObject *obBag; // @pyparm <o PyIPropertyBag>|bag||the caller's property bag.
	int clearDirty; // @pyparm int|clearDirty||Specifies whether to clear the dirty flag.
	int saveAllProperties; // @pyparm int|saveProperties||Specifies whether to save all properties or just those that have changed
	if ( !PyArg_ParseTuple(args, "Oii:Save", &obBag, &clearDirty, &saveAllProperties) )
		return NULL;

	IPersistPropertyBag *pIPPB = GetI(self);
	if ( pIPPB == NULL )
		return NULL;

	IPropertyBag *pIPB;
	if ( !PyCom_InterfaceFromPyObject(obBag, IID_IPropertyBag, (LPVOID*)&pIPB, FALSE) )
		return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIPPB->Save(pIPB, clearDirty, saveAllProperties);
	pIPB->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPPB, IID_IPersistPropertyBag);

	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod |PyIStorage|MoveElementTo|Copies or moves a substorage or stream from this storage object to another storage object.
PyObject *PyIStorage::MoveElementTo(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|name||A string that contains the name of the element in this storage object to be moved or copied.
	// @pyparm <o PyIStorage>|stgDest||<o PyIStorage> for the destination storage object.
	// @pyparm string|newName||A string that contains the new name for the element in its new storage object.
	// @pyparm int|grfFlags||Specifies whether the operation should be a move (STGMOVE_MOVE) or a copy (STGMOVE_COPY). See the STGMOVE enumeration.
	PyObject *obName, *obNewName;
	PyObject *obpstgDest;
	DWORD grfFlags;
	if ( !PyArg_ParseTuple(args, "OOOi:MoveElementTo", &obName, &obpstgDest, &obNewName, &grfFlags) )
		return NULL;
	IStorage *pstgDest;
	BOOL bPythonIsHappy = TRUE;
	BSTR bstrName, bstrNewName;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &bstrName);
	if (!PyWinObject_AsBstr(obNewName, &bstrNewName))
		bPythonIsHappy = FALSE;
	if (!PyCom_InterfaceFromPyObject(obpstgDest, IID_IStorage, (void **)&pstgDest, FALSE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->MoveElementTo( bstrName, pstgDest, bstrNewName, grfFlags );
	pstgDest->Release();
	PY_INTERFACE_POSTCALL;
	PyWinObject_FreeBstr(bstrName);
	PyWinObject_FreeBstr(bstrNewName);
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);
	Py_INCREF(Py_None);
	return Py_None;

}
// @pymethod |PyIStorage|CopyTo|Copies the entire contents of an open storage object to another storage object.
PyObject *PyIStorage::CopyTo(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm [<o PyIID>,]|rgiidExclude||List of IID's to be excluded.
	// @pyparm <o SNB>|snbExclude||Reserved for later - Must be None
	// @pyparm <o PyIStorage>|stgDest||The open storage object into which this storage object is to be copied. 
	// The destination storage object can be a different implementation of the <o PyIStorage> interface from the source storage object. 
	// Thus, <om IStorage::CopyTo> can only use publicly available methods of the destination storage object. 
	// If stgDest is open in transacted mode, it can be reverted by calling its <om PyIStorage::Revert> method. 
	DWORD ciidExclude = 0;
	PyObject *obSeqExclude;
	PyObject *obpstgDest;
	char *temp;
	if ( !PyArg_ParseTuple(args, "OzO:CopyTo", &obSeqExclude, &temp, &obpstgDest) )
		return NULL;
	IID *pExclude;
	if (obSeqExclude==Py_None)
		pExclude = NULL;
	else {
		if (!PySequence_Check(obSeqExclude)) {
			PyErr_SetString(PyExc_TypeError, "Argument 1 must be a sequence of IID's, or None");
			return NULL;
		}
		ciidExclude = PySequence_Length(obSeqExclude);
		pExclude = new IID[ciidExclude];
		if (pExclude==NULL) {
			PyErr_SetString(PyExc_MemoryError, "Allocating array of IID's");
			return NULL;
		}
		for (DWORD i=0;i<ciidExclude;i++) {
			PyObject *ob = PySequence_GetItem(obSeqExclude, (int)i);
			BOOL ok = PyWinObject_AsIID(ob, pExclude+i);
			Py_XDECREF(ob);
			if (!ok) {
				delete [] pExclude;
				return NULL;
			}
		}
	}
	IStorage *pstgDest;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyObject(obpstgDest, IID_IStorage, (void **)&pstgDest, FALSE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) {
		return NULL;
		delete [] pExclude;
	}
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->CopyTo( ciidExclude, pExclude, NULL, pstgDest );
	delete [] pExclude;
	pstgDest->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod <o PyIStorage>|pythoncom|StgOpenStorage|Opens an existing root storage object in the file system.
PyObject *pythoncom_StgOpenStorage(PyObject *self, PyObject *args)
{
	PyObject *temp = NULL;
	DWORD reserved = 0;
	PyObject *obName;
	DWORD mode;
	IStorage *pResult;
	PyObject *obOther;

	if (!PyArg_ParseTuple(args, "OOi|Oi:StgOpenStorage",
		               &obName, // @pyparm string|name||Name of the stream, or possibly None if storageOther is non None.
					   &obOther, // @pyparm <o PyIStorage>|other||Usually None, or another parent storage.
					   &mode, // @pyparm int|mode||Specifies the access mode used to open the storage.  A combination of the storagecon.STGM_* constants.
					   &temp, // @pyparm object|snbExclude|None|Not yet supported - must be None
					   &reserved)) // @pyparm int|reserved|0|A reserved value
		return NULL;
	PyWin_AutoFreeBstr bstrName;
	if ( !PyWinObject_AsAutoFreeBstr(obName, &bstrName, TRUE) )
		return NULL;
	IStorage *pOther;
	if (!PyCom_InterfaceFromPyObject(obOther, IID_IStorage, (void **)&pOther, TRUE))
		return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = StgOpenStorage(bstrName, pOther, mode, NULL, reserved, &pResult);
	if (pOther) pOther->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	return PyCom_PyObjectFromIUnknown(pResult, IID_IStorage, FALSE);
}
// @pymethod |PyIShellLibrary|SetDefaultSaveFolder|Sets the default save location
PyObject *PyIShellLibrary::SetDefaultSaveFolder(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	DEFAULTSAVEFOLDERTYPE Type;
	IShellItem *SaveFolder;
	PyObject *obSaveFolder;
	// @pyparm int|Type||Specifies public or private save location, shellcon.DSFT_*
	// @pyparm <o PyIShellItem>|SaveFolder||New default location, must be in the library
	if (!PyArg_ParseTuple(args, "iO:SetDefaultSaveFolder", &Type, &obSaveFolder))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obSaveFolder, IID_IShellItem, (void **)&SaveFolder, FALSE))
		return NULL;

	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->SetDefaultSaveFolder(Type, SaveFolder);
	SaveFolder->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	Py_INCREF(Py_None);
	return Py_None;
}
Example #14
0
STDMETHODIMP PyGConnectionPoint::GetConnectionPointContainer( IConnectionPointContainer **ppCPC)
{
	PY_GATEWAY_METHOD;
	if (ppCPC==NULL) return E_POINTER;
	PyObject *result;
	HRESULT hr = InvokeViaPolicy("GetConnectionPointContainer", &result, NULL);
	if (FAILED(hr)) return hr;
	if (!PyCom_InterfaceFromPyObject(result, IID_IConnectionPointContainer, (void **)ppCPC))
		hr = PyCom_SetCOMErrorFromPyException(GetIID());
	Py_XDECREF(result);
	return hr;
}
STDMETHODIMP PyGShellItemResources::EnumResources(
		IEnumResources ** ppenumr)
{
	PY_GATEWAY_METHOD;
	if (ppenumr==NULL) return E_POINTER;
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("EnumResources", &result);
	if (FAILED(hr)) return hr;
	if (!PyCom_InterfaceFromPyObject(result, IID_IEnumResources, (void **)ppenumr, FALSE))
		hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("EnumResources");
	Py_DECREF(result);
	return hr;
}
STDMETHODIMP PyGConnectionPointContainer::FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP)
{
	PY_GATEWAY_METHOD;
	if (ppCP==NULL) return E_POINTER;
	*ppCP = NULL;
	PyObject *obIID = PyWinObject_FromIID(riid);
	PyObject *result;
	HRESULT hr = InvokeViaPolicy("FindConnectionPoint", &result, "O", obIID);
	Py_XDECREF(obIID);
	if (FAILED(hr)) return hr;
	if (result != Py_None && !PyCom_InterfaceFromPyObject(result, IID_IConnectionPoint, (void **)ppCP))
		hr = PyCom_SetCOMErrorFromPyException(GetIID());
	Py_XDECREF(result);
	return (hr==S_OK && *ppCP==NULL) ? CONNECT_E_NOCONNECTION : hr;
}
// @pymethod <o PyIID>|pythoncom|ReadClassStm|Retrieves the CLSID from a stream
PyObject *pythoncom_ReadClassStm(PyObject *self, PyObject *args)
{
	PyObject *obStm;
	if (!PyArg_ParseTuple(args, "O:ReadClassStm",
		&obStm))	// @pyparm <o PyIStream>|Stm||An IStream interface
		return NULL;
	IStream *pStm;
	if (!PyCom_InterfaceFromPyObject(obStm, IID_IStream, (void **)&pStm, FALSE))
		return NULL;
	CLSID clsidRet;
	PY_INTERFACE_PRECALL;
	HRESULT hr = ReadClassStm(pStm, &clsidRet);
	pStm->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	return PyWinObject_FromIID(clsidRet);
}
// @pymethod <o PyIID>|pythoncom|ReadClassStg|Reads a CLSID from a storage object.
PyObject *pythoncom_ReadClassStg(PyObject *self, PyObject *args)
{
	PyObject *obStg;
	if (!PyArg_ParseTuple(args, "O:ReadClassStg",
					   &obStg)) // @pyparm <o PyIStorage>|storage||The storage to read the CLSID from.
		return NULL;
	IStorage *pStorage;
	if (!PyCom_InterfaceFromPyObject(obStg, IID_IStorage, (void **)&pStorage, FALSE))
		return NULL;
	CLSID clsidRet;
	PY_INTERFACE_PRECALL;
	HRESULT hr = ReadClassStg(pStorage, &clsidRet);
	pStorage->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	return PyWinObject_FromIID(clsidRet);
}
Example #19
0
STDMETHODIMP PyGEnumConnectionPoints::Next( 
            /* [in] */ ULONG celt,
            /* [length_is][size_is][out] */ IConnectionPoint **rgVar,
            /* [out] */ ULONG __RPC_FAR *pCeltFetched)
{
	PY_GATEWAY_METHOD;
	PyObject *result;
	HRESULT hr = InvokeViaPolicy("Next", &result, "i", celt);
	if ( FAILED(hr) )
		return hr;

	if ( !PySequence_Check(result) )
		goto error;
	int len;
	len = PyObject_Length(result);
	if ( len == -1 )
		goto error;
	if ( len > (int)celt)
		len = celt;

	if ( pCeltFetched )
		*pCeltFetched = len;

	int i;
	for ( i = 0; i < len; ++i )
	{
		PyObject *ob = PySequence_GetItem(result, i);
		if ( ob == NULL )
			goto error;

		if ( !PyCom_InterfaceFromPyObject(ob, IID_IConnectionPoint, reinterpret_cast<void **>(&rgVar[i]), FALSE) )
		{
			Py_DECREF(result);
			return PyCom_SetCOMErrorFromPyException(IID_IEnumConnectionPoints);
		}
	}

	Py_DECREF(result);

	return len < (int)celt ? S_FALSE : S_OK;

  error:
	PyErr_Clear();	// just in case
	Py_DECREF(result);
	return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnumConnectionPoints);
}
STDMETHODIMP PyGPropertyDescriptionList::GetAt(
	UINT iElem,
	REFIID riid,
	void ** ppv)
{
	PY_GATEWAY_METHOD;

	PyObject *obriid = PyWinObject_FromIID(riid);
	if (obriid==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetAt");
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetAt", &result, "kO", iElem, obriid);
	Py_DECREF(obriid);
	if (FAILED(hr)) return hr;
	if (!PyCom_InterfaceFromPyObject(result, riid, ppv, FALSE))
		hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetAt");
	Py_DECREF(result);
	return hr;
}
STDMETHODIMP PyGShellItemResources::CreateResource(
		/* [in] */ const SHELL_ITEM_RESOURCE * pcsir,
		/* [in] */ REFIID riid,
		/* [out] */ void ** ppv)
{
	PY_GATEWAY_METHOD;
	PyObject *obpcsir = PyWinObject_FromSHELL_ITEM_RESOURCE(pcsir);
	if (obpcsir==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateResource");
	if (ppv==NULL) return E_POINTER;
	PyObject *obriid;
	obriid = PyWinObject_FromIID(riid);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("CreateResource", &result, "OO", obpcsir, obriid);
	Py_DECREF(obpcsir);
	Py_XDECREF(obriid);
	if (FAILED(hr)) return hr;
	if (!PyCom_InterfaceFromPyObject(result, riid, ppv, FALSE))
		hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("OpenResource");
	Py_DECREF(result);
	return hr;
}
// @pymethod object|PyIPropertyBag|Read|Called by the control to read a property from the storage provided by the container.
PyObject *PyIPropertyBag::Read(PyObject *self, PyObject *args)
{
	int varType = VT_EMPTY;
	PyObject *obLog = NULL;
	PyObject *obName;
	// @pyparm str|propName||Name of the property to read.
	// @pyparm int|propType||The type of the object to read.  Must be a VT_* Variant Type constant.
	// @pyparm <o PyIErrorLog>|errorLog|None|The caller's <o PyIErrorLog> object in which the property bag stores any errors that occur during reads. Can be None in which case the caller is not interested in errors.
	if ( !PyArg_ParseTuple(args, "O|iO:Read", &obName, &varType, &obLog) )
		return NULL;

	IPropertyBag *pIPB = GetI(self);
	if ( pIPB == NULL )
		return NULL;

	TmpWCHAR Name;
	if (!PyWinObject_AsWCHAR(obName, &Name))
		return NULL;
	IErrorLog *pIEL = NULL;
	if ( obLog != NULL && obLog != Py_None &&
		!PyCom_InterfaceFromPyObject(obLog, IID_IErrorLog, (LPVOID*)&pIEL, FALSE) )
		return NULL;

	VARIANT var;
	VariantInit(&var);
	V_VT(&var) = varType;	// ### do we need to set anything more?

	PY_INTERFACE_PRECALL;
	HRESULT hr = pIPB->Read(Name, &var, pIEL);
	if ( pIEL != NULL )
		pIEL->Release();
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPB, IID_IPropertyBag);

	PyObject *result = PyCom_PyObjectFromVariant(&var);
	VariantClear(&var);
	// @comm The result is a Python object, mapped from a COM VARIANT of type as specified in the propType parameter.
	return result;
}
// @pymethod <o PyIStorage>|PyIStorage|OpenStorage|Opens an existing storage object with the specified name in the specified access mode.
PyObject *PyIStorage::OpenStorage(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|pwcsName||Name of the storage, or None.
	// @pyparm <o PyIStorage>|pstgPriority||If the pstgPriority parameter is not None, it is a <o PyIStorage> object to a previous opening of an element of the storage object, 
	// usually one that was opened in priority mode. The storage object should be closed and re-opened 
	// according to grfMode. When the <om PyIStorage.OpenStorage> method returns, pstgPriority is no longer valid - use the result value. 
	// If the pstgPriority parameter is None, it is ignored.
	// @pyparm int|grfMode||Specifies the access mode to use when opening the storage object. See the STGM enumeration values for descriptions of the possible values. Whatever other modes you may choose, you must at least specify STGM_SHARE_EXCLUSIVE when calling this method. 
	// @pyparm <o SNB>|snbExclude||Reserved for later - Must be None
	// @pyparm int|reserved|0|Reserved integer param.
	PyObject *obName;
	PyObject *obpstgPriority;
	DWORD grfMode;
	DWORD reserved = 0;
	char *temp = NULL;
	if ( !PyArg_ParseTuple(args, "OOi|zi:OpenStorage", &obName, &obpstgPriority, &grfMode, &temp, &reserved) )
		return NULL;
	IStorage *pstgPriority;
	IStorage *ppstg;
	BOOL bPythonIsHappy = TRUE;
	BSTR bstrName;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &bstrName, TRUE);
	if (!PyCom_InterfaceFromPyObject(obpstgPriority, IID_IStorage, (void **)&pstgPriority, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->OpenStorage( bstrName, pstgPriority, grfMode, NULL, reserved, &ppstg );
	if ( pstgPriority != NULL )
		pstgPriority->Release();
	PyWinObject_FreeBstr(bstrName);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);

	return PyCom_PyObjectFromIUnknown(ppstg, IID_IStorage, FALSE);
}
// @pymethod |PyIApplicationDestinations|RemoveDestination|Removes a single entry from the jump lists
// @comm Does not remove pinned items
PyObject *PyIApplicationDestinations::RemoveDestination(PyObject *self, PyObject *args)
{
	IApplicationDestinations *pIAD = GetI(self);
	if ( pIAD == NULL )
		return NULL;
	IUnknown *punk;
	PyObject *obpunk;
	// @pyparm <o PyIUnknown>|punk||IShellItem or IShellLink representing an item in the application's jump list
	if ( !PyArg_ParseTuple(args, "O:RemoveDestination", &obpunk))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obpunk, IID_IUnknown, (void **)&punk, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAD->RemoveDestination( punk );
	punk->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAD, IID_IApplicationDestinations );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod |PyIObjectCollection|AddFromArray|Adds a number of objects contained in an <o PyIObjectArray> collection
PyObject *PyIObjectCollection::AddFromArray(PyObject *self, PyObject *args)
{
	IObjectCollection *pIOC = GetI(self);
	if ( pIOC == NULL )
		return NULL;
	IObjectArray *Source;
	PyObject *obSource;
	// @pyparm <o PyIObjectArray>|Source||Objects to be added to the collection
	if ( !PyArg_ParseTuple(args, "O:AddFromArray", &obSource))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obSource, IID_IObjectArray, (void **)&Source, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIOC->AddFromArray(Source);
	Source->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIOC, IID_IObjectCollection );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod |PyITransferSource|SetProperties|Specifies changes to be applied to items' properties
PyObject *PyITransferSource::SetProperties(PyObject *self, PyObject *args)
{
	ITransferSource *pITS = GetI(self);
	if ( pITS == NULL )
		return NULL;
	// @pyparm <o PyIPropertyChangeArray>|proparray||Property changes to be applied by <om PyITransferSource.ApplyPropertiesToItem>
	PyObject *obpproparray;
	IPropertyChangeArray * pproparray;
	if ( !PyArg_ParseTuple(args, "O:SetProperties", &obpproparray) )
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obpproparray, IID_IPropertyChangeArray, (void **)&pproparray, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pITS->SetProperties( pproparray );
	pproparray->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pITS, IID_ITransferSource );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod <o PyIStorage>|pythoncom|StgCreateDocfileOnILockBytes|Creates a new compound file storage object using the OLE-provided compound file implementation for the <o PyIStorage> interface.
PyObject *pythoncom_StgCreateDocfileOnILockBytes(PyObject *self, PyObject *args)
{
	DWORD reserved = 0;
	DWORD mode;
	IStorage *pResult;
	PyObject *obLockBytes;

	if (!PyArg_ParseTuple(args, "Oi|i:StgCreateDocfileOnILockBytes",
		               &obLockBytes, // @pyparm <o PyILockBytes>|lockBytes||The <o PyILockBytes> interface on the underlying byte array object on which to create a compound file.
					   &mode, // @pyparm int|mode||Specifies the access mode used to open the storage.
					   &reserved)) // @pyparm int|reserved|0|A reserved value
		return NULL;
	ILockBytes *plb;
	if (!PyCom_InterfaceFromPyObject(obLockBytes, IID_ILockBytes, (void **)&plb, FALSE))
		return NULL;

	PY_INTERFACE_PRECALL;
	HRESULT hr = StgCreateDocfileOnILockBytes(plb, mode, reserved, &pResult);
	plb->Release();
	PY_INTERFACE_POSTCALL;
	if (FAILED(hr)) return PyCom_BuildPyException(hr);
	return PyCom_PyObjectFromIUnknown(pResult, IID_IStorage, FALSE);
}
// @pymethod |PyIShellLibrary|RemoveFolder|Removes a folder
PyObject *PyIShellLibrary::RemoveFolder(PyObject *self, PyObject *args)
{
	IShellLibrary *pISL = GetI(self);
	if ( pISL == NULL )
		return NULL;
	IShellItem *Location;
	PyObject *obLocation;
	// @pyparm <o PyIShellItem>|Location||Shell item interface representing the folder
	if ( !PyArg_ParseTuple(args, "O:RemoveFolder", &obLocation))
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obLocation, IID_IShellItem, (void **)&Location, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pISL->RemoveFolder(Location);
	Location->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
	Py_INCREF(Py_None);
	return Py_None;
}
// @pymethod int|PyIActiveScriptSite|OnScriptError|
PyObject *PyIActiveScriptSite::OnScriptError(PyObject *self, PyObject *args)
{
	PY_INTERFACE_METHOD;
	PyObject *obASE;
	if (!PyArg_ParseTuple(args, "O:OnScriptError", &obASE))
		return NULL;

	IActiveScriptSite *pMySite = GetI(self);
	if (pMySite==NULL) return NULL;

	IActiveScriptError *pASE;
	if (!PyCom_InterfaceFromPyObject(obASE, IID_IActiveScriptError, (void **)&pASE, FALSE))
		return NULL;
	PY_INTERFACE_PRECALL;
	SCODE sc = pMySite->OnScriptError(pASE);
	pASE->Release();
	PY_INTERFACE_POSTCALL;
	// no idea why, but under ASP, OnScriptError() will often return
	// with a KeyboardInterrup set!
	PyWin_MakePendingCalls();
	if (sc != E_FAIL && FAILED(sc)) // E_FAIL is documented as a normal retval.
		return SetPythonCOMError(self, sc);
	return PyInt_FromLong(sc);
}
// @pymethod |PyIObjectCollection|AddObject|Adds a single object to the collection
PyObject *PyIObjectCollection::AddObject(PyObject *self, PyObject *args)
{
	IObjectCollection *pIOC = GetI(self);
	if ( pIOC == NULL )
		return NULL;
	IUnknown *punk;
	PyObject *obpunk;
	// @pyparm <o PyIUnknown>|punk||Object to be added
	if ( !PyArg_ParseTuple(args, "O:AddObject", &obpunk) )
		return NULL;
	if (!PyCom_InterfaceFromPyObject(obpunk, IID_IUnknown, (void **)&punk, FALSE))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIOC->AddObject( punk );
	punk->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIOC, IID_IObjectCollection );
	Py_INCREF(Py_None);
	return Py_None;

}