本文整理汇总了C++中IStream_AddRef函数的典型用法代码示例。如果您正苦于以下问题:C++ IStream_AddRef函数的具体用法?C++ IStream_AddRef怎么用?C++ IStream_AddRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IStream_AddRef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IStream_fnQueryInterface
/**************************************************************************
* IStream_fnQueryInterface
*/
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface,
REFIID riid,
LPVOID *ppvObj)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IStream))
{
*ppvObj = This;
}
if(*ppvObj)
{
IStream_AddRef((IStream*)*ppvObj);
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
示例2: IWICStreamImpl_InitializeFromIStreamRegion
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion(IWICStream *iface,
IStream *pIStream, ULARGE_INTEGER ulOffset, ULARGE_INTEGER ulMaxSize)
{
IWICStreamImpl *This = impl_from_IWICStream(iface);
StreamOnStreamRange *pObject;
TRACE("(%p,%p)\n", iface, pIStream);
if (!pIStream) return E_INVALIDARG;
if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(StreamOnStreamRange));
if (!pObject) return E_OUTOFMEMORY;
pObject->IStream_iface.lpVtbl = &StreamOnStreamRange_Vtbl;
pObject->ref = 1;
IStream_AddRef(pIStream);
pObject->stream = pIStream;
pObject->pos.QuadPart = 0;
pObject->offset = ulOffset;
pObject->max_size = ulMaxSize;
InitializeCriticalSection(&pObject->lock);
pObject->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StreamOnStreamRange.lock");
if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
{
/* Some other thread set the stream first. */
IStream_Release(&pObject->IStream_iface);
return WINCODEC_ERR_WRONGSTATE;
}
return S_OK;
}
示例3: IcnsEncoder_Initialize
static HRESULT WINAPI IcnsEncoder_Initialize(IWICBitmapEncoder *iface,
IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
HRESULT hr = S_OK;
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
EnterCriticalSection(&This->lock);
if (This->icns_family)
{
hr = WINCODEC_ERR_WRONGSTATE;
goto end;
}
This->icns_family = (IconFamilyHandle)NewHandle(0);
if (!This->icns_family)
{
WARN("error creating icns family\n");
hr = E_FAIL;
goto end;
}
IStream_AddRef(pIStream);
This->stream = pIStream;
end:
LeaveCriticalSection(&This->lock);
return hr;
}
示例4: ProtocolStream_QueryInterface
static HRESULT WINAPI ProtocolStream_QueryInterface(IStream *iface,
REFIID riid, void **ppv)
{
ProtocolStream *This = STREAM_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = STREAM(This);
} else if(IsEqualGUID(&IID_ISequentialStream, riid)) {
TRACE("(%p)->(IID_ISequentialStream %p)\n", This, ppv);
*ppv = STREAM(This);
} else if(IsEqualGUID(&IID_IStream, riid)) {
TRACE("(%p)->(IID_IStream %p)\n", This, ppv);
*ppv = STREAM(This);
}
if(*ppv) {
IStream_AddRef(STREAM(This));
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
}
示例5: StgStreamImpl_QueryInterface
/***
* This implements the IUnknown method QueryInterface for this
* class
*/
static HRESULT WINAPI StgStreamImpl_QueryInterface(
IStream* iface,
REFIID riid, /* [in] */
void** ppvObject) /* [iid_is][out] */
{
StgStreamImpl* This = impl_from_IStream(iface);
if (ppvObject==0)
return E_INVALIDARG;
*ppvObject = 0;
if (IsEqualIID(&IID_IUnknown, riid) ||
IsEqualIID(&IID_ISequentialStream, riid) ||
IsEqualIID(&IID_IStream, riid))
{
*ppvObject = &This->IStream_iface;
}
else
return E_NOINTERFACE;
IStream_AddRef(iface);
return S_OK;
}
示例6: PngEncoder_Initialize
static HRESULT WINAPI PngEncoder_Initialize(IWICBitmapEncoder *iface,
IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
PngEncoder *This = impl_from_IWICBitmapEncoder(iface);
jmp_buf jmpbuf;
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
EnterCriticalSection(&This->lock);
if (This->png_ptr)
{
LeaveCriticalSection(&This->lock);
return WINCODEC_ERR_WRONGSTATE;
}
/* initialize libpng */
This->png_ptr = ppng_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!This->png_ptr)
{
LeaveCriticalSection(&This->lock);
return E_FAIL;
}
This->info_ptr = ppng_create_info_struct(This->png_ptr);
if (!This->info_ptr)
{
ppng_destroy_write_struct(&This->png_ptr, NULL);
This->png_ptr = NULL;
LeaveCriticalSection(&This->lock);
return E_FAIL;
}
IStream_AddRef(pIStream);
This->stream = pIStream;
/* set up setjmp/longjmp error handling */
if (setjmp(jmpbuf))
{
ppng_destroy_write_struct(&This->png_ptr, &This->info_ptr);
This->png_ptr = NULL;
IStream_Release(This->stream);
This->stream = NULL;
LeaveCriticalSection(&This->lock);
return E_FAIL;
}
ppng_set_error_fn(This->png_ptr, jmpbuf, user_error_fn, user_warning_fn);
/* set up custom i/o handling */
ppng_set_write_fn(This->png_ptr, This, user_write_data, user_flush);
LeaveCriticalSection(&This->lock);
return S_OK;
}
示例7: BmpEncoder_Initialize
static HRESULT WINAPI BmpEncoder_Initialize(IWICBitmapEncoder *iface,
IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
BmpEncoder *This = impl_from_IWICBitmapEncoder(iface);
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
IStream_AddRef(pIStream);
This->stream = pIStream;
return S_OK;
}
示例8: CopyStgMedium
/***********************************************************************
* CopyStgMedium ([email protected])
*/
HRESULT WINAPI CopyStgMedium(const STGMEDIUM *src, STGMEDIUM *dst)
{
TRACE("(%p %p)\n", src, dst);
if(!src || !dst)
return E_POINTER;
*dst = *src;
switch(dst->tymed) {
case TYMED_NULL:
break;
case TYMED_FILE:
if(src->u.lpszFileName && !src->pUnkForRelease) {
DWORD size = (strlenW(src->u.lpszFileName)+1)*sizeof(WCHAR);
dst->u.lpszFileName = CoTaskMemAlloc(size);
if(!dst->u.lpszFileName)
return E_OUTOFMEMORY;
memcpy(dst->u.lpszFileName, src->u.lpszFileName, size);
}
break;
case TYMED_ISTREAM:
if(dst->u.pstm)
IStream_AddRef(dst->u.pstm);
break;
case TYMED_ISTORAGE:
if(dst->u.pstg)
IStorage_AddRef(dst->u.pstg);
break;
case TYMED_HGLOBAL:
if(dst->u.hGlobal) {
SIZE_T size = GlobalSize(src->u.hGlobal);
char *src_ptr, *dst_ptr;
dst->u.hGlobal = GlobalAlloc(GMEM_FIXED, size);
if(!dst->u.hGlobal)
return E_OUTOFMEMORY;
dst_ptr = GlobalLock(dst->u.hGlobal);
src_ptr = GlobalLock(src->u.hGlobal);
memcpy(dst_ptr, src_ptr, size);
GlobalUnlock(src_ptr);
GlobalUnlock(dst_ptr);
}
break;
default:
FIXME("Unimplemented tymed %d\n", src->tymed);
}
if(dst->pUnkForRelease)
IUnknown_AddRef(dst->pUnkForRelease);
return S_OK;
}
示例9: stgmed_stream_get_result
static HRESULT stgmed_stream_get_result(stgmed_obj_t *obj, DWORD bindf, void **result)
{
ProtocolStream *stream = (ProtocolStream*)obj;
if(!(bindf & BINDF_ASYNCHRONOUS) && stream->buf->file == INVALID_HANDLE_VALUE
&& (stream->buf->hres != S_FALSE || stream->buf->size))
return INET_E_DATA_NOT_AVAILABLE;
IStream_AddRef(STREAM(stream));
*result = STREAM(stream);
return S_OK;
}
示例10: TestStream_QueryInterface
static HRESULT WINAPI TestStream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
{
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_ISequentialStream) ||
IsEqualIID(riid, &IID_IStream))
{
*ppv = iface;
IStream_AddRef(iface);
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
示例11: JpegEncoder_Initialize
static HRESULT WINAPI JpegEncoder_Initialize(IWICBitmapEncoder *iface,
IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
jmp_buf jmpbuf;
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOption);
EnterCriticalSection(&This->lock);
if (This->initialized)
{
LeaveCriticalSection(&This->lock);
return WINCODEC_ERR_WRONGSTATE;
}
pjpeg_std_error(&This->jerr);
This->jerr.error_exit = error_exit_fn;
This->jerr.emit_message = emit_message_fn;
This->cinfo.err = &This->jerr;
This->cinfo.client_data = jmpbuf;
if (setjmp(jmpbuf))
{
LeaveCriticalSection(&This->lock);
return E_FAIL;
}
pjpeg_CreateCompress(&This->cinfo, JPEG_LIB_VERSION, sizeof(struct jpeg_compress_struct));
This->stream = pIStream;
IStream_AddRef(pIStream);
This->dest_mgr.next_output_byte = This->dest_buffer;
This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
This->dest_mgr.init_destination = dest_mgr_init_destination;
This->dest_mgr.empty_output_buffer = dest_mgr_empty_output_buffer;
This->dest_mgr.term_destination = dest_mgr_term_destination;
This->cinfo.dest = &This->dest_mgr;
This->initialized = TRUE;
LeaveCriticalSection(&This->lock);
return S_OK;
}
示例12: BmpEncoder_CreateNewFrame
static HRESULT WINAPI BmpEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
{
BmpEncoder *This = impl_from_IWICBitmapEncoder(iface);
BmpFrameEncode *encode;
HRESULT hr;
static const PROPBAG2 opts[1] =
{
{ PROPBAG2_TYPE_DATA, VT_BOOL, 0, 0, (LPOLESTR)wszEnableV5Header32bppBGRA },
};
TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
if (This->frame) return WINCODEC_ERR_UNSUPPORTEDOPERATION;
if (!This->stream) return WINCODEC_ERR_NOTINITIALIZED;
if (ppIEncoderOptions)
{
hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions);
if (FAILED(hr)) return hr;
}
encode = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpFrameEncode));
if (!encode)
{
IPropertyBag2_Release(*ppIEncoderOptions);
*ppIEncoderOptions = NULL;
return E_OUTOFMEMORY;
}
encode->IWICBitmapFrameEncode_iface.lpVtbl = &BmpFrameEncode_Vtbl;
encode->ref = 2;
IStream_AddRef(This->stream);
encode->stream = This->stream;
encode->initialized = FALSE;
encode->width = 0;
encode->height = 0;
encode->bits = NULL;
encode->format = NULL;
encode->xres = 0.0;
encode->yres = 0.0;
encode->lineswritten = 0;
encode->colors = 0;
encode->committed = FALSE;
*ppIFrameEncode = &encode->IWICBitmapFrameEncode_iface;
This->frame = encode;
return S_OK;
}
示例13: MSI_RecordCopyField
UINT MSI_RecordCopyField( MSIRECORD *in_rec, UINT in_n,
MSIRECORD *out_rec, UINT out_n )
{
UINT r = ERROR_SUCCESS;
msiobj_lock( &in_rec->hdr );
if ( in_n > in_rec->count || out_n > out_rec->count )
r = ERROR_FUNCTION_FAILED;
else if ( in_rec != out_rec || in_n != out_n )
{
LPWSTR str;
MSIFIELD *in, *out;
in = &in_rec->fields[in_n];
out = &out_rec->fields[out_n];
switch ( in->type )
{
case MSIFIELD_NULL:
break;
case MSIFIELD_INT:
out->u.iVal = in->u.iVal;
break;
case MSIFIELD_INTPTR:
out->u.pVal = in->u.pVal;
break;
case MSIFIELD_WSTR:
if ((str = msi_strdupW( in->u.szwVal, in->len )))
{
out->u.szwVal = str;
out->len = in->len;
}
else r = ERROR_OUTOFMEMORY;
break;
case MSIFIELD_STREAM:
IStream_AddRef( in->u.stream );
out->u.stream = in->u.stream;
break;
default:
ERR("invalid field type %d\n", in->type);
}
if (r == ERROR_SUCCESS)
out->type = in->type;
}
msiobj_unlock( &in_rec->hdr );
return r;
}
示例14: MSI_RecordSetIStream
UINT MSI_RecordSetIStream( MSIRECORD *rec, UINT iField, IStream *stm )
{
TRACE("%p %d %p\n", rec, iField, stm);
if( iField > rec->count )
return ERROR_INVALID_FIELD;
MSI_FreeField( &rec->fields[iField] );
rec->fields[iField].type = MSIFIELD_STREAM;
rec->fields[iField].u.stream = stm;
IStream_AddRef( stm );
return ERROR_SUCCESS;
}
示例15: MSI_RecordGetIStream
UINT MSI_RecordGetIStream( MSIRECORD *rec, UINT iField, IStream **pstm)
{
TRACE("%p %d %p\n", rec, iField, pstm);
if( iField > rec->count )
return ERROR_INVALID_FIELD;
if( rec->fields[iField].type != MSIFIELD_STREAM )
return ERROR_INVALID_FIELD;
*pstm = rec->fields[iField].u.stream;
IStream_AddRef( *pstm );
return ERROR_SUCCESS;
}