HRESULT _IFUNC BOleInProcServer::SaveCompleted(IStorage* pStgSaved) { LPPERSISTSTORAGE pPersistCache; if (SUCCEEDED(pDefHandler->QueryInterface(IID_IPersistStorage, &(LPVOID) pPersistCache))) { pPersistCache->SaveCompleted(pStgSaved); pPersistCache->Release(); } return BOleSite::SaveCompleted(pStgSaved); }
void CEx27bView::OnEditCopyto() { // Copy text to an .STG file (nothing special about STG ext) CFileDialog dlg(FALSE, "stg", "*.stg"); if (dlg.DoModal() != IDOK) { return; } CEx27bDoc* pDoc = GetDocument(); // Create a structured storage home for the object (m_pStgSub). // Create a root storage file, then a substorage named "sub." LPSTORAGE pStgRoot; VERIFY(::StgCreateDocfile(dlg.GetPathName().AllocSysString(), STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE, 0, &pStgRoot) == S_OK); ASSERT(pStgRoot != NULL); LPSTORAGE pStgSub; VERIFY(pStgRoot->CreateStorage(CEx27bDoc::s_szSub, STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStgSub) == S_OK); ASSERT(pStgSub != NULL); // Get the IPersistStorage* for the object LPPERSISTSTORAGE pPS = NULL; VERIFY(pDoc->m_lpOleObj->QueryInterface(IID_IPersistStorage, (void**) &pPS) == S_OK); // Finally, save the object in its new home in the user's file VERIFY(::OleSave(pPS, pStgSub, FALSE) == S_OK); // FALSE means different stg pPS->SaveCompleted(NULL); // What does this do? pPS->Release(); pStgSub->Release(); pStgRoot->Release(); }