本文整理汇总了C++中LPSTORAGE类的典型用法代码示例。如果您正苦于以下问题:C++ LPSTORAGE类的具体用法?C++ LPSTORAGE怎么用?C++ LPSTORAGE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPSTORAGE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteToStorage
BOOL CSummInfo::WriteToStorage(LPSTORAGE lpRootStg)
{
if (lpRootStg != NULL)
{
LPSTREAM lpStream = NULL;
if (FAILED(lpRootStg->CreateStream(szSummInfo,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE,
0, 0, &lpStream)))
{
TRACE(_T("CreateStream failed\n"));
return FALSE;
}
else
{
if(!m_propSet.WriteToStream(lpStream))
{
TRACE(_T("WriteToStream failed\n"));
return FALSE;
}
lpRootStg->Commit(STGC_DEFAULT);
lpStream->Release();
return TRUE;
}
}
return FALSE;
}
示例2: WriteThreadProc
UINT WriteThreadProc(LPVOID pParam)
{
USES_CONVERSION;
LPSTORAGE pStgRoot = NULL;
g_nIndent = 0;
VERIFY(::StgCreateDocfile(T2COLE(g_szRootStorageName),
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
0, &pStgRoot) == S_OK);
ReadDirectory("\\", pStgRoot);
pStgRoot->Release();
AfxMessageBox("Write complete");
return 0;
}
示例3: ASSERT_VALID
void COleServerItem::GetEmbedSourceData(LPSTGMEDIUM lpStgMedium)
{
ASSERT_VALID(this);
ASSERT(AfxIsValidAddress(lpStgMedium, sizeof(STGMEDIUM)));
LPLOCKBYTES lpLockBytes;
SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpLockBytes != NULL);
LPSTORAGE lpStorage;
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &lpStorage);
if (sc != S_OK)
{
VERIFY(lpLockBytes->Release() == 0);
AfxThrowOleException(sc);
}
ASSERT(lpStorage != NULL);
// setup for save copy as
COleServerDoc* pDoc = GetDocument();
pDoc->m_bSameAsLoad = FALSE;
pDoc->m_bRemember = FALSE;
TRY
{
OnSaveEmbedding(lpStorage);
pDoc->CommitItems(FALSE);
}
CATCH_ALL(e)
{
// release storage and lock bytes
VERIFY(lpStorage->Release() == 0);
VERIFY(lpLockBytes->Release() == 0);
pDoc->m_bSameAsLoad = TRUE;
pDoc->m_bRemember = TRUE;
THROW_LAST();
}
END_CATCH_ALL
pDoc->m_bSameAsLoad = TRUE;
pDoc->m_bRemember = TRUE;
lpLockBytes->Release();
// add it to the data source
lpStgMedium->tymed = TYMED_ISTORAGE;
lpStgMedium->pstg = lpStorage;
lpStgMedium->pUnkForRelease = NULL;
}
示例4: 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--;
}
示例5: FARINTERNAL_
FARINTERNAL_(void) UtRemoveExtraOlePresStreams(LPSTORAGE pstg, int iStart)
{
VDATEHEAP();
HRESULT hr; // error code from stream deletion
OLECHAR szName[sizeof(OLE_PRESENTATION_STREAM)/sizeof(OLECHAR)];
// space for the stream names
// if the stream number is invalid, do nothing
if ((iStart < 0) || (iStart >= OLE_MAX_PRES_STREAMS))
return;
// create presentation stream name
_xstrcpy(szName, OLE_PRESENTATION_STREAM);
UtGetPresStreamName(szName, iStart);
// for each of these streams that exists, get rid of it
while((hr = pstg->DestroyElement(szName)) == NOERROR)
{
// if we've gotten to the end of the possible streams, quit
if (++iStart >= OLE_MAX_PRES_STREAMS)
break;
// Get the next presentation stream name
UtGetPresStreamName(szName, iStart);
}
// since the only reason these streams should be open, the first
// failure had better be that the file was not found, and not
// anything else (such as STG_E_ACCESSDENIED)
AssertSz(hr == STG_E_FILENOTFOUND,
"UtRemoveExtraOlePresStreams failure");
}
示例6: Save
STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
{
if( NULL == pStg )
return E_INVALIDARG;
if( fSameAsLoad && (S_FALSE == IsDirty()) )
return S_OK;
LPSTREAM pStm = NULL;
HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data",
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Save(pStm, fSameAsLoad);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
示例7: ReadFromStorage
BOOL CSummInfo::ReadFromStorage(LPSTORAGE lpRootStg)
{
if (lpRootStg != NULL)
{
LPSTREAM lpStream = NULL;
if (FAILED(lpRootStg->OpenStream(szSummInfo,
NULL, STGM_SHARE_EXCLUSIVE|STGM_READ,
0, &lpStream)))
{
TRACE(_T("OpenStream failed\n"));
return FALSE;
}
else
{
if (!m_propSet.ReadFromStream(lpStream))
{
TRACE(_T("ReadFromStream failed\n"));
return FALSE;
}
m_pSection = m_propSet.GetSection(FMTID_SummaryInformation);
lpStream->Release();
return TRUE;
}
}
return FALSE;
}
示例8: ReadThreadProc
UINT ReadThreadProc(LPVOID pParam)
{
USES_CONVERSION;
LPSTORAGE pStgRoot = NULL;
// doesn't work without STGM_SHARE_EXCLUSIVE
g_nIndent = 0;
if (::StgOpenStorage(T2COLE(g_szRootStorageName), NULL,
STGM_READ | STGM_SHARE_EXCLUSIVE,
NULL, 0, &pStgRoot) == S_OK) {
ASSERT(pStgRoot!= NULL);
ReadStorage(pStgRoot);
pStgRoot->Release();
}
else {
AfxMessageBox("Storage file not available or not readable");
}
AfxMessageBox("Read complete");
return 0;
}
示例9: dlg
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();
}
示例10: Load
STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
{
if( NULL == pStg )
return E_INVALIDARG;
LPSTREAM pStm = NULL;
HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Load(pStm);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
示例11: CommitItems
void COleDocument::CommitItems(BOOL bSuccess, LPSTORAGE pNewStorage)
{
// special 'Commit' phase for COleClientItem items
POSITION pos = GetStartPosition();
COleClientItem* pItem;
while ((pItem = GetNextClientItem(pos)) != NULL)
{
// Set m_lpNewStorage so we can pass it to IPersistStorage::SaveCompleted
// in COleClientItem::CommitItem. m_bNeedCommit was set in
// HandsOffStorage.
if (pItem->m_bNeedCommit && pNewStorage)
{
if (pItem->m_lpNewStorage)
pItem->m_lpNewStorage->Release();
pNewStorage->AddRef();
pItem->m_lpNewStorage = pNewStorage;
}
// calling CommitItem with FALSE causes the object to revert
// to the original storage. Calling CommitItem TRUE causes
// the item to adopt the new storage created in the Serialize
// function.
pItem->CommitItem(bSuccess);
}
}
示例12: GetDocument
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);
}
示例13: ASSERT
BOOL COleDocument::OnSaveDocument(LPCTSTR lpszPathName)
// lpszPathName must be fully qualified
{
ASSERT(lpszPathName == NULL || AfxIsValidString(lpszPathName));
// use default implementation if 'docfile' not enabled
if (!m_bCompoundFile && m_lpRootStg == NULL)
{
ASSERT(lpszPathName != NULL);
return CDocument::OnSaveDocument(lpszPathName);
}
LPSTORAGE lpOrigStg = NULL;
if (lpszPathName != NULL)
m_bSameAsLoad = AfxComparePath(m_strPathName, lpszPathName);
BOOL bResult = FALSE;
TRY
{
// open new root storage if necessary
if (lpszPathName != NULL && !m_bSameAsLoad)
{
// temporarily detach current storage
lpOrigStg = m_lpRootStg;
m_lpRootStg = NULL;
LPSTORAGE lpStorage;
const CStringW strPathName(lpszPathName);
SCODE sc = ::StgCreateDocfile(strPathName.GetString(),
STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_DENY_WRITE|STGM_CREATE,
0, &lpStorage);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpStorage != NULL);
m_lpRootStg = lpStorage;
}
ASSERT(m_lpRootStg != NULL);
// use helper to save to root storage
SaveToStorage();
if (lpszPathName != NULL)
{
// commit each of the items
CommitItems(m_bRemember && !m_bSameAsLoad);
// mark document as clean if remembering the storage
if (m_bRemember)
SetModifiedFlag(FALSE);
// remember correct storage or release save copy as storage
if (!m_bSameAsLoad)
{
if (m_bRemember)
{
// Save As case -- m_stgRoot is new storage, forget old storage
lpOrigStg->Release();
}
else
{
// Save Copy As case -- m_stgRoot should hook up to m_stgOrig.
m_lpRootStg->Release();
m_lpRootStg = lpOrigStg;
}
}
}
bResult = TRUE;
}
CATCH_ALL(e)
{
if (lpOrigStg != NULL)
{
// save as failed: abort new storage, and re-attach original
RELEASE(m_lpRootStg);
m_lpRootStg = lpOrigStg;
}
if (lpszPathName == NULL)
{
THROW_LAST();
}
TRY
{
ReportSaveLoadException(lpszPathName, e,
TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);
}
END_TRY
DELETE_EXCEPTION(e);
}
END_CATCH_ALL
// cleanup
m_bSameAsLoad = TRUE;
m_bRemember = TRUE;
return bResult;
}
示例14: ResultFromScode
FARINTERNAL UtContentsStmTo10NativeStm
(LPSTORAGE pstg, REFCLSID rclsid, BOOL fDeleteSrcStm, UINT FAR* puiStatus)
{
CLIPFORMAT cf;
LPOLESTR lpszUserType = NULL;
HRESULT error;
LPSTREAM pstmSrc = NULL;
LPSTREAM pstmDst = NULL;
*puiStatus = NULL;
if (error = ReadFmtUserTypeStg(pstg, &cf, &lpszUserType))
return error;
if (! ((cf == CF_DIB && rclsid == CLSID_PBrush)
|| (cf == CF_METAFILEPICT && rclsid == CLSID_MSDraw))) {
error = ResultFromScode(DV_E_CLIPFORMAT);
goto errRtn;
}
if (error = pstg->OpenStream(OLE_CONTENTS_STREAM, NULL,
(STGM_READ|STGM_SHARE_EXCLUSIVE),
0, &pstmSrc)) {
*puiStatus |= CONVERT_NOSOURCE;
// check whether OLE10_NATIVE_STREAM exists
if (pstg->OpenStream(OLE10_NATIVE_STREAM, NULL,
(STGM_READ|STGM_SHARE_EXCLUSIVE), 0, &pstmDst))
*puiStatus |= CONVERT_NODESTINATION;
else {
pstmDst->Release();
pstmDst = NULL;
}
goto errRtn;
}
if (error = OpenOrCreateStream(pstg, OLE10_NATIVE_STREAM, &pstmDst)) {
*puiStatus |= CONVERT_NODESTINATION;
goto errRtn;
}
if (cf == CF_METAFILEPICT)
error = UtPlaceableMFStmToMSDrawNativeStm(pstmSrc, pstmDst);
else
error = UtDIBFileStmToPBrushNativeStm(pstmSrc, pstmDst);
errRtn:
if (pstmDst)
pstmDst->Release();
if (pstmSrc)
pstmSrc->Release();
if (error == NOERROR) {
LPOLESTR lpszProgId = NULL;
ProgIDFromCLSID(rclsid, &lpszProgId);
error = WriteFmtUserTypeStg(pstg,
RegisterClipboardFormat(lpszProgId),
lpszUserType);
if (lpszProgId)
delete lpszProgId;
}
if (error == NOERROR) {
if (fDeleteSrcStm)
pstg->DestroyElement(OLE_CONTENTS_STREAM);
} else {
pstg->DestroyElement(OLE10_NATIVE_STREAM);
}
if (lpszUserType)
delete lpszUserType;
return error;
}
示例15: SendMessage
void App::GetProperties()
{
LPSTORAGE pStorage = NULL;
IPropertySetStorage* pPropertySetStorage = NULL;
IPropertyStorage* pSummaryInfoStorage = NULL;
IPropertyStorage* pDocumentSummaryInfoStorage = NULL;
IPropertyStorage* pUserDefinedPropertyStorage = NULL;
wchar_t wfilename[_MAX_PATH];
char szBuf[256];
char filename[MAX_PATH];
SendMessage(GetDlgItem(hPropDialog, IDC_TITLE), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_SUBJECT), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_AUTHOR), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_MANAGER), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_COMPANY), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_CATEGORY), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_KEYWORDS), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_COMMENTS), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_CONTENTS), LB_RESETCONTENT, 0, 0);
ListView_DeleteAllItems(GetDlgItem(hPropDialog, IDC_CUSTOM));
int idx = SendMessage(hListBox, LB_GETCURSEL, 0, 0);
SendMessage(hListBox, LB_GETTEXT, idx, (LPARAM)filename);
SetWindowText(hPropDialog, filename);
MultiByteToWideChar(CP_ACP, 0, filename, -1, wfilename, _MAX_PATH);
HRESULT res = StgOpenStorage(wfilename, (LPSTORAGE)0, STGM_DIRECT|STGM_READ|STGM_SHARE_EXCLUSIVE, NULL,0,&pStorage);
if (res!=S_OK) {
return;
}
// Get the Storage interface
if (S_OK != pStorage->QueryInterface(IID_IPropertySetStorage, (void**)&pPropertySetStorage)) {
pStorage->Release();
return;
}
// Get the SummaryInfo property set interface
if (S_OK == pPropertySetStorage->Open(FMTID_SummaryInformation, STGM_READ|STGM_SHARE_EXCLUSIVE, &pSummaryInfoStorage)) {
BOOL bFound = FALSE;
PROPSPEC PropSpec[5];
PROPVARIANT PropVar[5];
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = PID_TITLE;
PropSpec[1].ulKind = PRSPEC_PROPID;
PropSpec[1].propid = PID_SUBJECT;
PropSpec[2].ulKind = PRSPEC_PROPID;
PropSpec[2].propid = PID_AUTHOR;
PropSpec[3].ulKind = PRSPEC_PROPID;
PropSpec[3].propid = PID_KEYWORDS;
PropSpec[4].ulKind = PRSPEC_PROPID;
PropSpec[4].propid = PID_COMMENTS;
HRESULT hr = pSummaryInfoStorage->ReadMultiple(5, PropSpec, PropVar);
if (S_OK == hr) {
if (PropVar[0].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_TITLE), WM_SETTEXT, 0, (LPARAM)PropVar[0].pszVal);
}
if (PropVar[1].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_SUBJECT), WM_SETTEXT, 0, (LPARAM)PropVar[1].pszVal);
}
if (PropVar[2].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_AUTHOR), WM_SETTEXT, 0, (LPARAM)PropVar[2].pszVal);
}
if (PropVar[3].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_KEYWORDS), WM_SETTEXT, 0, (LPARAM)PropVar[3].pszVal);
}
if (PropVar[4].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_COMMENTS), WM_SETTEXT, 0, (LPARAM)PropVar[4].pszVal);
}
}
FreePropVariantArray(5, PropVar);
pSummaryInfoStorage->Release();
}
// Get the DocumentSummaryInfo property set interface
if (S_OK == pPropertySetStorage->Open(FMTID_DocSummaryInformation, STGM_READ|STGM_SHARE_EXCLUSIVE, &pDocumentSummaryInfoStorage)) {
BOOL bFound = FALSE;
PROPSPEC PropSpec[5];
PROPVARIANT PropVar[5];
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = PID_MANAGER;
PropSpec[1].ulKind = PRSPEC_PROPID;
PropSpec[1].propid = PID_COMPANY;
PropSpec[2].ulKind = PRSPEC_PROPID;
//.........这里部分代码省略.........