// @pymethod str|PyIPersistFile|GetCurFile|Gets the current name of the file associated with the object. PyObject *PyIPersistFile::GetCurFile(PyObject *self, PyObject *args) { IPersistFile *pIPF = GetI(self); if ( pIPF == NULL ) return NULL; LPOLESTR ppszFileName; if ( !PyArg_ParseTuple(args, ":GetCurFile") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPF->GetCurFile( &ppszFileName ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF, IID_IPersistFile); PyObject *pyretval = MakeOLECHARToObj(ppszFileName); CoTaskMemFree(ppszFileName); return pyretval; }
HRESULT CSite::Save(LPCTSTR pchPath) { HRESULT hr = S_OK; // OLECHAR szwName[256]; USES_CONVERSION; LPWSTR szwName = T2W(const_cast<LPTSTR>(pchPath)); LPOLESTR pszwName = szwName; LPOLESTR *ppszwName = &pszwName; IPersistFile* pPFile = NULL; hr = m_pObj->QueryInterface( IID_IPersistFile, (void **) &pPFile); if ( SUCCEEDED(hr) && pPFile) { if ( pchPath != NULL && *pchPath != 0) { // MultiByteToWideChar(CP_ACP, 0, pchPath, -1, szwName, 256); } else { hr = pPFile->GetCurFile(ppszwName); } if ( SUCCEEDED(hr) && ppszwName) { // Call Save on the IPersistFile hr = pPFile->Save(*ppszwName, TRUE); if ( SUCCEEDED(hr) ) { hr = pPFile->SaveCompleted(*ppszwName); } } ReleaseInterface(pPFile); } return hr; }