本文整理汇总了C++中IPersistStream::Save方法的典型用法代码示例。如果您正苦于以下问题:C++ IPersistStream::Save方法的具体用法?C++ IPersistStream::Save怎么用?C++ IPersistStream::Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistStream
的用法示例。
在下文中一共展示了IPersistStream::Save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveSerializedPropStorageToStream
HRESULT SaveSerializedPropStorageToStream(IPersistSerializedPropStorage *psps, IStream *pstm)
{
IPersistStream *pPersistStream;
HRESULT hr = psps->QueryInterface(IID_PPV_ARGS(&pPersistStream));
if (SUCCEEDED(hr))
{
// implement size limit here
hr = pPersistStream->Save(pstm, TRUE);
pPersistStream->Release();
}
return hr;
}
示例2: SaveGraph
/* 把当前工作的滤波器链表保存到*.grf */
void CVMR_Capture::SaveGraph(CString wFileName)
{
HRESULT hr;
{
IStorage* pStorage=NULL;
// First, create a document file that will hold the GRF file
hr = ::StgCreateDocfile(wFileName.AllocSysString(), STGM_CREATE|STGM_TRANSACTED|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &pStorage);
if (FAILED(hr))
{
AfxMessageBox(TEXT("Can not create a document"));
return;
}
// Next, create a stream to store.
WCHAR wszStreamName[] = L"ActiveMovieGraph";
IStream *pStream;
hr = pStorage->CreateStream(wszStreamName,STGM_WRITE|STGM_CREATE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStream);
if(FAILED(hr))
{
AfxMessageBox(TEXT("Can not create a stream"));
pStorage->Release();
return;
}
// The IpersistStream::Save method converts a stream
// into a persistent object.
IPersistStream *pPersist = NULL;
m_pGB->QueryInterface(IID_IPersistStream, reinterpret_cast<void**>(&pPersist));
hr = pPersist->Save(pStream, TRUE);
pStream->Release();
pPersist->Release();
if(SUCCEEDED(hr))
{
hr = pStorage->Commit(STGC_DEFAULT);
if (FAILED(hr))
{
AfxMessageBox(TEXT("can not store it"));
}
}
pStorage->Release();
}
}
示例3: HError
HRESULT CPkcs7::SaveIntoJavaClassFile(FILEHANDLE hFile,LPCOLESTR wszFileName,BOOL fClearDirty)
// Save this signed data (presumably already signed) into the right place in the class file
{
HRESULT hr = S_OK;
CFileStream stm;
if (stm.OpenFileForWriting(hFile, wszFileName, FALSE))
{
IPersistStream* pPerStream;
hr = CJavaClassFile::CreateInstance(NULL, IID_IPersistStream, (LPVOID*)&pPerStream);
if (hr == S_OK)
{
hr = pPerStream->Load(&stm); // load the class file
if (hr == S_OK)
{
BLOB b;
hr = CPersistMemoryHelper2::Save(&b, FALSE); // get our bits
if (hr == S_OK)
{
IInsertSig* pSig;
hr = pPerStream->QueryInterface(IID_IInsertSig, (LPVOID*)&pSig);
if (hr == S_OK)
{
hr = pSig->SaveSig(&b); // stuff our bits in
pSig->Release();
}
FreeTaskMem(b);
}
if (hr == S_OK)
{
stm.Reset();
stm.Truncate();
hr = pPerStream->Save(&stm, FALSE); // save the class file
}
}
pPerStream->Release();
}
}
else
hr = HError();
if (hr == S_OK && fClearDirty)
m_isDirty = FALSE;
return hr;
}
示例4: SaveGraphFile
// This code was also brazenly stolen from the DX9 SDK
// Pass it a file name in wszPath, and it will save the filter graph to that file.
HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath)
{
const WCHAR wszStreamName[] = L"ActiveMovieGraph";
HRESULT hr;
IStorage *pStorage = NULL;
// First, create a document file which will hold the GRF file
hr = StgCreateDocfile(
wszPath,
STGM_CREATE | STGM_TRANSACTED | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
0, &pStorage);
if(FAILED(hr))
{
return hr;
}
// Next, create a stream to store.
IStream *pStream;
hr = pStorage->CreateStream(
wszStreamName,
STGM_WRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
0, 0, &pStream);
if (FAILED(hr))
{
pStorage->Release();
return hr;
}
// The IPersistStream converts a stream into a persistent object.
IPersistStream *pPersist = NULL;
pGraph->QueryInterface(IID_IPersistStream, reinterpret_cast<void**>(&pPersist));
hr = pPersist->Save(pStream, TRUE);
pStream->Release();
pPersist->Release();
if (SUCCEEDED(hr))
{
hr = pStorage->Commit(STGC_DEFAULT);
}
pStorage->Release();
return hr;
}
示例5: SaveGraphFile
HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath)
{
const WCHAR wszStreamName[] = L"ActiveMovieGraph";
HRESULT hr;
IStorage *pStorage = NULL;
hr = StgCreateDocfile(
wszPath,
STGM_CREATE | STGM_TRANSACTED | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
0, &pStorage);
if(FAILED(hr))
{
return hr;
}
IStream *pStream;
hr = pStorage->CreateStream(
wszStreamName,
STGM_WRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
0, 0, &pStream);
if (FAILED(hr))
{
pStorage->Release();
return hr;
}
IPersistStream *pPersist = NULL;
pGraph->QueryInterface(IID_IPersistStream, (void**)&pPersist);
hr = pPersist->Save(pStream, TRUE);
pStream->Release();
pPersist->Release();
if (SUCCEEDED(hr))
{
hr = pStorage->Commit(STGC_DEFAULT);
}
pStorage->Release();
return hr;
}
示例6: PyCom_BuildPyException
// @pymethod |PyIPersistStream|Save|Saves an object to the specified stream.
PyObject *PyIPersistStream::Save(PyObject *self, PyObject *args)
{
IPersistStream *pMy = GetI(self);
if (pMy==NULL) return NULL;
PyObject *obStream;
int bClearDirty;
// @pyparm <o PyIStream>|stream||The stream to save to.
// @pyparm int|bClearDirty||Indicates whether to clear the dirty flag after the save is complete
if (!PyArg_ParseTuple(args, "Oi:Save", &obStream, &bClearDirty))
return NULL;
IStream *pStream;
if (!PyCom_InterfaceFromPyInstanceOrObject(obStream, IID_IStream, (void **)&pStream, FALSE /*bNoneOK*/))
return NULL;
PY_INTERFACE_PRECALL;
HRESULT hr = pMy->Save(pStream, bClearDirty);
pStream->Release();
PY_INTERFACE_POSTCALL;
if (FAILED(hr))
return PyCom_BuildPyException(hr, pMy, IID_IPersistStream);
Py_INCREF(Py_None);
return Py_None;
}
示例7: OnAddressBarBeginDrag
void Explorerplusplus::OnAddressBarBeginDrag(void)
{
IDragSourceHelper *pDragSourceHelper = NULL;
IDropSource *pDropSource = NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_DragDropHelper,NULL,CLSCTX_ALL,
IID_IDragSourceHelper,(LPVOID *)&pDragSourceHelper);
if(SUCCEEDED(hr))
{
hr = CreateDropSource(&pDropSource,DRAG_TYPE_LEFTCLICK);
if(SUCCEEDED(hr))
{
LPITEMIDLIST pidlDirectory = m_pActiveShellBrowser->QueryCurrentDirectoryIdl();
FORMATETC ftc[2];
STGMEDIUM stg[2];
SetFORMATETC(&ftc[0],(CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR),
NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL);
HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE,1000);
FILEGROUPDESCRIPTOR *pfgd = static_cast<FILEGROUPDESCRIPTOR *>(GlobalLock(hglb));
pfgd->cItems = 1;
FILEDESCRIPTOR *pfd = (FILEDESCRIPTOR *)((LPBYTE)pfgd + sizeof(UINT));
/* File information (name, size, date created, etc). */
pfd[0].dwFlags = FD_ATTRIBUTES|FD_FILESIZE;
pfd[0].dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
pfd[0].nFileSizeLow = 16384;
pfd[0].nFileSizeHigh = 0;
/* The name of the file will be the folder name, followed by .lnk. */
TCHAR szDisplayName[MAX_PATH];
GetDisplayName(pidlDirectory,szDisplayName,SHGDN_INFOLDER);
StringCchCat(szDisplayName,SIZEOF_ARRAY(szDisplayName),_T(".lnk"));
StringCchCopy(pfd[0].cFileName,SIZEOF_ARRAY(pfd[0].cFileName),szDisplayName);
GlobalUnlock(hglb);
stg[0].pUnkForRelease = 0;
stg[0].hGlobal = hglb;
stg[0].tymed = TYMED_HGLOBAL;
/* File contents. */
SetFORMATETC(&ftc[1],(CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILECONTENTS),
NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL);
hglb = GlobalAlloc(GMEM_MOVEABLE,16384);
IShellLink *pShellLink = NULL;
IPersistStream *pPersistStream = NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,
IID_IShellLink,(LPVOID*)&pShellLink);
if(SUCCEEDED(hr))
{
TCHAR szPath[MAX_PATH];
GetDisplayName(pidlDirectory,szPath,SHGDN_FORPARSING);
pShellLink->SetPath(szPath);
hr = pShellLink->QueryInterface(IID_IPersistStream,(LPVOID*)&pPersistStream);
if(SUCCEEDED(hr))
{
IStream *pStream = NULL;
CreateStreamOnHGlobal(hglb,FALSE,&pStream);
hr = pPersistStream->Save(pStream,TRUE);
}
}
GlobalUnlock(hglb);
stg[1].pUnkForRelease = 0;
stg[1].hGlobal = hglb;
stg[1].tymed = TYMED_HGLOBAL;
IDataObject *pDataObject = NULL;
POINT pt = {0,0};
hr = CreateDataObject(ftc,stg,&pDataObject,2);
pDragSourceHelper->InitializeFromWindow(m_hAddressBar,&pt,pDataObject);
DWORD dwEffect;
DoDragDrop(pDataObject,pDropSource,DROPEFFECT_LINK,&dwEffect);
CoTaskMemFree(pidlDirectory);
//.........这里部分代码省略.........