本文整理汇总了C++中LPSTREAM::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPSTREAM::Release方法的具体用法?C++ LPSTREAM::Release怎么用?C++ LPSTREAM::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPSTREAM
的用法示例。
在下文中一共展示了LPSTREAM::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyBinAttachToFile
bool CMapiMessage::CopyBinAttachToFile(LPATTACH lpAttach,
nsIFile **tmp_file)
{
nsCOMPtr<nsIFile> _tmp_file;
nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR,
"mapiattach.tmp",
getter_AddRefs(_tmp_file));
NS_ENSURE_SUCCESS(rv, false);
rv = _tmp_file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
NS_ENSURE_SUCCESS(rv, false);
nsCString tmpPath;
_tmp_file->GetNativePath(tmpPath);
LPSTREAM lpStreamFile;
HRESULT hr = CMapiApi::OpenStreamOnFile(gpMapiAllocateBuffer, gpMapiFreeBuffer, STGM_READWRITE | STGM_CREATE,
const_cast<char*>(tmpPath.get()), NULL, &lpStreamFile);
if (HR_FAILED(hr)) {
MAPI_TRACE1("~~ERROR~~ OpenStreamOnFile failed - temp path: %s\r\n",
tmpPath.get());
return false;
}
bool bResult = true;
LPSTREAM lpAttachStream;
hr = lpAttach->OpenProperty(PR_ATTACH_DATA_BIN, &IID_IStream, 0, 0, (LPUNKNOWN *)&lpAttachStream);
if (HR_FAILED(hr)) {
MAPI_TRACE0("~~ERROR~~ OpenProperty failed for PR_ATTACH_DATA_BIN.\r\n");
lpAttachStream = NULL;
bResult = false;
}
else {
STATSTG st;
hr = lpAttachStream->Stat(&st, STATFLAG_NONAME);
if (HR_FAILED(hr)) {
MAPI_TRACE0("~~ERROR~~ Stat failed for attachment stream\r\n");
bResult = false;
}
else {
hr = lpAttachStream->CopyTo(lpStreamFile, st.cbSize, NULL, NULL);
if (HR_FAILED(hr)) {
MAPI_TRACE0("~~ERROR~~ Attach Stream CopyTo temp file failed.\r\n");
bResult = false;
}
}
}
if (lpAttachStream)
lpAttachStream->Release();
lpStreamFile->Release();
if (!bResult)
_tmp_file->Remove(false);
else
CallQueryInterface(_tmp_file, tmp_file);
return bResult;
}
示例2: save_bitmap
/*static */
bool display_t::save_bitmap(const char *szFileName, HBITMAP bmp, HPALETTE pal /*= NULL*/)
{
START_FUNCTION_BOOL();
PICTDESC pdPictDesc;
pdPictDesc.cbSizeofstruct = sizeof(PICTDESC);
pdPictDesc.picType = PICTYPE_BITMAP;
pdPictDesc.bmp.hbitmap = bmp;
pdPictDesc.bmp.hpal = pal;
LPPICTURE plPicture = NULL;
HRESULT hResult = OleCreatePictureIndirect(&pdPictDesc, IID_IPicture, false, reinterpret_cast<void**>(&plPicture));
if (!SUCCEEDED(hResult))
{
break;
}
LPSTREAM lpStream = NULL;
hResult = CreateStreamOnHGlobal(0, true, &lpStream);
if (!SUCCEEDED(hResult))
{
plPicture->Release();
return false;
}
LONG lBytesStreamed = 0;
hResult = plPicture->SaveAsFile(lpStream, true, &lBytesStreamed);
HANDLE hFile = CreateFileA(szFileName, GENERIC_WRITE, FILE_SHARE_READ, 0,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (!SUCCEEDED(hResult) || !hFile)
{
lpStream->Release();
plPicture->Release();
break;
}
HGLOBAL hgMemory = 0;
GetHGlobalFromStream(lpStream, &hgMemory);
LPVOID lpData = GlobalLock(hgMemory);
DWORD dwBytesWritten = 0;
bool bResult = !!WriteFile(hFile, lpData, lBytesStreamed, &dwBytesWritten, 0);
bResult &= (dwBytesWritten == static_cast<DWORD>(lBytesStreamed));
GlobalUnlock(hgMemory);
CloseHandle(hFile);
lpStream->Release();
plPicture->Release();
END_FUNCTION_BOOL();
}
示例3: GetLinkSourceData
BOOL COleServerItem::GetLinkSourceData(LPSTGMEDIUM lpStgMedium)
{
ASSERT_VALID(this);
ASSERT(AfxIsValidAddress(lpStgMedium, sizeof(STGMEDIUM)));
LPOLEOBJECT lpOleObject = GetOleObject();
ASSERT(lpOleObject != NULL);
// get moniker from ole object
LPMONIKER lpMoniker;
SCODE sc = lpOleObject->GetMoniker(OLEGETMONIKER_TEMPFORUSER,
OLEWHICHMK_OBJFULL, &lpMoniker);
if (sc != S_OK)
{
TRACE0("Warning: unable to get moniker for object.\n");
return FALSE;
}
ASSERT(lpMoniker != NULL);
// create a memory based stream to write the moniker to
LPSTREAM lpStream;
if (::CreateStreamOnHGlobal(NULL, TRUE, &lpStream) != S_OK)
{
lpMoniker->Release();
AfxThrowMemoryException();
}
ASSERT(lpStream != NULL);
// write the moniker to the stream, and add it to the clipboard
sc = ::OleSaveToStream(lpMoniker, lpStream);
lpMoniker->Release();
if (sc != S_OK)
{
lpStream->Release();
AfxThrowOleException(sc);
}
// write the class ID of the document to the stream as well
COleLinkingDoc* pDoc = GetDocument();
ASSERT(pDoc->m_pFactory != NULL);
sc = WriteClassStm(lpStream, pDoc->m_pFactory->GetClassID());
if (sc != S_OK)
{
lpStream->Release();
AfxThrowOleException(sc);
}
// setup the STGMEDIUM
lpStgMedium->tymed = TYMED_ISTREAM;
lpStgMedium->pstm = lpStream;
lpStgMedium->pUnkForRelease = NULL;
return TRUE;
}
示例4: bkimg
static Gdiplus::Image* bkimg(int rcid) {
HRSRC hrsc = ::FindResource(hInst, MAKEINTRESOURCE(rcid), TEXT("PNG"));
DWORD size = ::SizeofResource(hInst, hrsc);
LPVOID hg = ::LoadResource(hInst, hrsc);
HGLOBAL mem = ::GlobalAlloc(GMEM_MOVEABLE, size);
Gdiplus::Image* img = 0;
if (mem) {
LPVOID pmem = ::GlobalLock(mem);
if (pmem) {
::CopyMemory(pmem, hg, size);
LPSTREAM is;
if (::CreateStreamOnHGlobal(pmem, FALSE, &is) == S_OK) {
Gdiplus::Image* m = new Gdiplus::Image(is);
is->Release();
if (m->GetLastStatus() != Gdiplus::Ok) {
delete m;
return img;
}
img = m;
}
::GlobalUnlock(mem);
}
::GlobalFree(mem);
}
return img;
}
示例5: _AfxLoadStreamFromPropset
LPSTREAM AFXAPI _AfxLoadStreamFromPropset(CPropertySection& psec, LPCTSTR pszPropName,
DWORD& vtType)
{
ASSERT(AfxIsValidString(pszPropName));
vtType = VT_EMPTY;
DWORD dwPropID;
CProperty* pprop = NULL;
LPSTREAM pstm = NULL;
if (psec.GetID(pszPropName, &dwPropID) &&
((pprop = psec.GetProperty(dwPropID)) != NULL))
{
vtType = pprop->GetType();
if ((vtType == VT_BLOB) || (vtType == VT_BLOB_PROPSET))
{
pstm = _AfxCreateMemoryStream();
if (pstm != NULL)
{
if (!_AfxInitStreamDataFromBlobProp(pstm, pprop))
{
pstm->Release();
pstm = NULL;
}
}
}
}
return pstm;
}
示例6: LoadSrcImage
void CScratchPadDlg::LoadSrcImage()
{
HINSTANCE hResInstance = AfxGetResourceHandle( );
HRSRC res = FindResource(hResInstance,
MAKEINTRESOURCE(IDB_BITMAP1),L"BINARY");
if (res)
{
HGLOBAL mem = LoadResource(hResInstance, res);
void *data = LockResource(mem);
size_t len = SizeofResource(hResInstance, res);
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, len);
LPVOID pvData = GlobalLock( hGlobal );
memcpy(pvData,data,len);
GlobalUnlock(hGlobal);
LPSTREAM pStream = NULL;
HRESULT hr = CreateStreamOnHGlobal( hGlobal, TRUE, &pStream );
using namespace Gdiplus;
m_pSrcBitmap = new Bitmap(pStream,false);
pStream->Release();
}
}
示例7: 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;
};
示例8: LoadFromBuffer
BOOL CGifImage::LoadFromBuffer(const BYTE* lpBuf, DWORD dwSize)
{
if (NULL == lpBuf || dwSize <= 0)
return FALSE;
HGLOBAL hGlobal = ::GlobalAlloc(GHND, dwSize);
if (NULL == hGlobal)
return FALSE;
LPVOID lpBuffer = ::GlobalLock(hGlobal);
if (NULL == lpBuffer)
{
::GlobalFree(hGlobal);
return FALSE;
}
memcpy(lpBuffer, lpBuf, dwSize);
::GlobalUnlock(hGlobal);
LPSTREAM lpStream = NULL;
HRESULT hr = ::CreateStreamOnHGlobal(hGlobal, TRUE, &lpStream);
if (hr != S_OK)
{
::GlobalFree(hGlobal);
return FALSE;
}
BOOL bRet = LoadFromIStream(lpStream);
lpStream->Release();
return bRet;
}
示例9: 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;
}
示例10: 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;
}
示例11: FileUpload
BOOL FileUpload(Zimbra::Rpc::ZimbraConnection *z_connection, LPWSTR *ppwszToken)
{
LOGFN_INTERNAL_NO;
LPSTR pszTestFile = "E:\\temp\\aa.log";
LPSTREAM pStreamFile = NULL;
HRESULT hr = OpenStreamOnFile(MAPIAllocateBuffer, MAPIFreeBuffer, STGM_READ,
(LPWSTR)pszTestFile, NULL, &pStreamFile);
if (FAILED(hr))
{
LOG_ERROR(_T("failed to OpenStreamOnFile call: %x"), hr);
return FALSE;
}
HANDLE hFile = CreateFile(L"E:\\temp\\aa.log", GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwFileSize = GetFileSize(hFile, NULL);
CloseHandle(hFile);
_tprintf(_T(" File Upload size=%d bytes\n"), dwFileSize);
BOOL bResult = z_connection->DoFileUpload(pStreamFile, dwFileSize,
L"/service/upload?fmt=raw", ppwszToken, NULL);
pStreamFile->Release();
return bResult;
}
示例12: LoadFromResource
BOOL CImageEx::LoadFromResource(HINSTANCE hInstance, LPCTSTR pszResourceName, LPCTSTR pszResType)
{
HRSRC hRsrc = ::FindResource(hInstance, pszResourceName, pszResType);
if (NULL == hRsrc)
return FALSE;
DWORD dwSize = ::SizeofResource(hInstance, hRsrc);
if (0 == dwSize)
return FALSE;
HGLOBAL hGlobal = ::LoadResource(hInstance, hRsrc);
if (NULL == hGlobal)
return FALSE;
LPVOID pBuffer = ::LockResource(hGlobal);
if (NULL == pBuffer)
{
::FreeResource(hGlobal);
return FALSE;
}
HGLOBAL hGlobal2 = ::GlobalAlloc(GHND, dwSize);
if (NULL == hGlobal2)
{
::FreeResource(hGlobal);
return FALSE;
}
LPVOID pBuffer2 = ::GlobalLock(hGlobal2);
if (NULL == pBuffer2)
{
::GlobalFree(hGlobal2);
::FreeResource(hGlobal);
return FALSE;
}
memcpy(pBuffer2, pBuffer, dwSize);
::GlobalUnlock(hGlobal2);
LPSTREAM pStream = NULL;
HRESULT hr = ::CreateStreamOnHGlobal(hGlobal2, TRUE, &pStream);
if (hr != S_OK)
{
::GlobalFree(hGlobal2);
::FreeResource(hGlobal);
return FALSE;
}
BOOL bRet = LoadFromIStream(pStream);
if (pStream)
pStream->Release();
::FreeResource(hGlobal);
return bRet;
}
示例13: SaveBitmap
/////////////////////////////////////////////////////////////////////////////////////////
// Utility to save a bitmap to file for later examination. Used for debugging only.
// Based on an article by "gelbert" on www.experts-exchange.com at
// http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20193761.html
//
// This version is a member function and instead of taking an HBITMAP as the 2nd
// parameter, it take a reference to a CBitmap. Otherwise, it is identical.
/////////////////////////////////////////////////////////////////////////////////////////
BOOL CSliderCtrlEx::SaveBitmap(LPCSTR lpFileName, CBitmap &hBitmap, HPALETTE hPal)
{
BOOL bResult = FALSE;
PICTDESC stPictDesc;
stPictDesc.cbSizeofstruct = sizeof(PICTDESC);
stPictDesc.picType = PICTYPE_BITMAP;
stPictDesc.bmp.hbitmap = hBitmap;
stPictDesc.bmp.hpal = hPal;
LPPICTURE pPicture;
HRESULT hr = OleCreatePictureIndirect( &stPictDesc, IID_IPicture, FALSE,
reinterpret_cast<void**>(&pPicture) );
if ( SUCCEEDED(hr) )
{
LPSTREAM pStream;
hr = CreateStreamOnHGlobal( NULL, TRUE, &pStream );
if ( SUCCEEDED(hr) )
{
long lBytesStreamed = 0;
hr = pPicture->SaveAsFile( pStream, TRUE, &lBytesStreamed );
if ( SUCCEEDED(hr) )
{
HANDLE hFile = CreateFile(_T(lpFileName),
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL );
if ( hFile )
{
HGLOBAL hMem = NULL;
GetHGlobalFromStream( pStream, &hMem );
LPVOID lpData = GlobalLock( hMem );
DWORD dwBytesWritten;
bResult = WriteFile( hFile, lpData, lBytesStreamed, &dwBytesWritten, NULL );
bResult &= ( dwBytesWritten == (DWORD)lBytesStreamed );
// clean up
GlobalUnlock(hMem);
CloseHandle(hFile);
}
}
// clean up
pStream->Release();
}
// clean up
pPicture->Release();
}
return bResult;
}
示例14: 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--;
}
示例15: XGif_SetImageRes
/// @brief ÉèÖÃGIF¶¯»Í¼Æ¬,´Ó×ÊÔ´ÖмÓÔØͼƬ.
/// @param hEle ÔªËؾä±ú.
/// @param id ×ÊÔ´ID.
/// @param pType ×ÊÔ´ÀàÐÍ.
void WINAPI XGif_SetImageRes(HELE hEle,int id,wchar_t *pType)
{
IsGifDebug(hEle,__FUNCTION__);
gif_ *pObject=(gif_*)hEle;
if(pObject->pGif)
{
delete pObject->pGif;
pObject->pGif=NULL;
}
if(pType)
{
HMODULE hInst=GetModuleHandle(NULL);
wchar_t * lpRes=MAKEINTRESOURCE(id);
HRSRC hRsrc=::FindResource(hInst,lpRes,pType);
if(NULL==hRsrc) return ;
HGLOBAL hGlobal=LoadResource(hInst,hRsrc);
DWORD dwSize =SizeofResource(hInst,hRsrc);
LPVOID lpData =LockResource(hGlobal);
HGLOBAL hJPG = ::GlobalAlloc(GMEM_MOVEABLE, dwSize);
LPVOID lpJGP = ::GlobalLock(hJPG);
memcpy(lpJGP, lpData, dwSize);
::GlobalUnlock(hJPG);
LPSTREAM pstm =NULL;
HRESULT hr =CreateStreamOnHGlobal(hJPG, TRUE, &pstm);
assert(SUCCEEDED(hr) && pstm);
pObject->pGif=new ImageEx(pstm);
pstm->Release();
BOOL hrr=FreeResource(hGlobal);
if(Gdiplus::Ok != (pObject->pGif->GetLastStatus()))
{
delete pObject->pGif;
pObject->pGif=NULL;
}
if(pObject->pGif->InitAnimation(0,0))
SetTimer(XEle_GetHWnd(hEle),(int)hEle,100,Gif_TimerProc);
}
}