当前位置: 首页>>代码示例>>C++>>正文


C++ LPSTORAGE::OpenStorage方法代码示例

本文整理汇总了C++中LPSTORAGE::OpenStorage方法的典型用法代码示例。如果您正苦于以下问题:C++ LPSTORAGE::OpenStorage方法的具体用法?C++ LPSTORAGE::OpenStorage怎么用?C++ LPSTORAGE::OpenStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPSTORAGE的用法示例。


在下文中一共展示了LPSTORAGE::OpenStorage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadStorage

void ReadStorage(LPSTORAGE pStg)
// reads one storage -- recursive calls for substorages
{
    USES_CONVERSION;
    LPSTORAGE pSubStg = NULL;
    LPSTREAM pStream = NULL;
    LPENUMSTATSTG pEnum = NULL;
    LPMALLOC pMalloc = NULL; // for freeing statstg
    STATSTG statstg;
    ULONG nLength;
    BYTE buffer[101];

    g_nIndent++;
    ::CoGetMalloc(MEMCTX_TASK, &pMalloc); // assumes AfxOleInit
                                          //  was called
    VERIFY(pStg->EnumElements(0, NULL, 0, &pEnum) == S_OK);
    while (pEnum->Next(1, &statstg, NULL) == S_OK) {
      if (statstg.type == STGTY_STORAGE) {
        VERIFY(pStg->OpenStorage(statstg.pwcsName, NULL,
               STGM_READ | STGM_SHARE_EXCLUSIVE,
               NULL, 0, &pSubStg) == S_OK);
        ASSERT(pSubStg != NULL);
        TRACE("%0.*sStorage = %s\n", (g_nIndent - 1) * 4,
              g_szBlanks, OLE2CT(statstg.pwcsName));
        ReadStorage(pSubStg);
        pSubStg->Release();
      }
      else if (statstg.type == STGTY_STREAM) {
        VERIFY(pStg->OpenStream(statstg.pwcsName, NULL,
               STGM_READ | STGM_SHARE_EXCLUSIVE,
               0, &pStream) == S_OK);
        ASSERT(pStream != NULL);
        TRACE("%0.*sStream = %s\n", (g_nIndent - 1) * 4,
               g_szBlanks, OLE2CT(statstg.pwcsName));
        pStream->Read(buffer, 100, &nLength);
        buffer[nLength] = '\0';
        TRACE("%s\n", buffer);
        pStream->Release();
      }
      else {
        ASSERT(FALSE);  // LockBytes?
      }
      pMalloc->Free(statstg.pwcsName); // avoids memory leaks
    }
    pMalloc->Release();
    pEnum->Release();
    g_nIndent--;
}
开发者ID:jiayuehua,项目名称:InsideVC,代码行数:48,代码来源:ReadThread.cpp

示例2: dlg

void CEx27bView::OnEditPastefrom() 
{
	CEx27bDoc* pDoc = GetDocument();
    // Paste from an .STG file
    CFileDialog dlg(TRUE, "stg", "*.stg");
    if (dlg.DoModal() != IDOK) {
        return;
    }
    // Open the storage and substorage
	LPSTORAGE pStgRoot;
	VERIFY(::StgOpenStorage(dlg.GetPathName().AllocSysString(), NULL,
		   STGM_READ|STGM_SHARE_EXCLUSIVE,
		   NULL, 0, &pStgRoot) == S_OK);
	ASSERT(pStgRoot != NULL);
	
	LPSTORAGE pStgSub;
	VERIFY(pStgRoot->OpenStorage(CEx27bDoc::s_szSub, NULL,
		   STGM_READ|STGM_SHARE_EXCLUSIVE,
		   NULL, 0, &pStgSub) == S_OK);
	ASSERT(pStgSub != NULL);

    // Copy the object data from the user storage to the temporary storage
	VERIFY(pStgSub->CopyTo(NULL, NULL, NULL, 
		   pDoc->m_pTempStgSub)  == S_OK);
    // Finally, load the object -- pClientSite not necessary
	LPOLECLIENTSITE pClientSite =
		(LPOLECLIENTSITE) pDoc->GetInterface(&IID_IOleClientSite);
	ASSERT(pClientSite != NULL);
	pDoc->DeleteContents();
	VERIFY(::OleLoad(pDoc->m_pTempStgSub, IID_IOleObject, pClientSite,
		  (void**) &pDoc->m_lpOleObj) == S_OK);
	SetViewAdvise();
	pStgSub->Release();
	pStgRoot->Release();
	GetSize();
    pDoc->SetModifiedFlag();
    pDoc->UpdateAllViews(NULL);
}
开发者ID:jiayuehua,项目名称:InsideVC,代码行数:38,代码来源:ex27bView.cpp


注:本文中的LPSTORAGE::OpenStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。