本文整理汇总了C++中IStream_Seek函数的典型用法代码示例。如果您正苦于以下问题:C++ IStream_Seek函数的具体用法?C++ IStream_Seek怎么用?C++ IStream_Seek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IStream_Seek函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msi_dump_stream_to_file
static UINT msi_dump_stream_to_file( IStream *stm, LPCWSTR name )
{
ULARGE_INTEGER size;
LARGE_INTEGER pos;
IStream *out;
DWORD stgm;
HRESULT r;
stgm = STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_FAILIFTHERE;
r = SHCreateStreamOnFileW( name, stgm, &out );
if( FAILED( r ) )
return ERROR_FUNCTION_FAILED;
pos.QuadPart = 0;
r = IStream_Seek( stm, pos, STREAM_SEEK_END, &size );
if( FAILED( r ) )
goto end;
pos.QuadPart = 0;
r = IStream_Seek( stm, pos, STREAM_SEEK_SET, NULL );
if( FAILED( r ) )
goto end;
r = IStream_CopyTo( stm, out, size, NULL, NULL );
end:
IStream_Release( out );
if( FAILED( r ) )
return ERROR_FUNCTION_FAILED;
return ERROR_SUCCESS;
}
示例2: report_data
static inline HRESULT report_data(BindStatusCallback *This)
{
FORMATETC formatetc = {0, NULL, 1, -1, TYMED_ISTREAM};
STGMEDIUM stgmedium;
LARGE_INTEGER off;
ULARGE_INTEGER size;
HRESULT hres;
off.QuadPart = 0;
hres = IStream_Seek(This->stream, off, STREAM_SEEK_CUR, &size);
if(FAILED(hres))
return hres;
hres = IStream_Seek(This->stream, off, STREAM_SEEK_SET, NULL);
if(FAILED(hres))
return hres;
stgmedium.tymed = TYMED_ISTREAM;
stgmedium.u.pstm = This->stream;
stgmedium.pUnkForRelease = NULL;
hres = IBindStatusCallback_OnDataAvailable(This->bsc,
BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
size.u.LowPart, &formatetc, &stgmedium);
IStream_Release(This->stream);
This->stream = NULL;
return hres;
}
示例3: IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList
static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
/*ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);*/
HRESULT hr = E_FAIL;
DMUS_PRIVATE_CHUNK Chunk;
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
if (pChunk->fccID != DMUS_FOURCC_SEGTRACK_LIST) {
ERR_(dmfile)(": %s chunk should be a SEGTRACK list\n", debugstr_fourcc (pChunk->fccID));
return E_FAIL;
}
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
ListCount[0] = 0;
do {
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGTRACK_CHUNK: {
TRACE_(dmfile)(": segment trigger track chunk\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case FOURCC_LIST: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
ListCount[1] = 0;
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGMENTS_LIST: {
TRACE_(dmfile)(": SEGMENTS list\n");
hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (iface, &Chunk, pStm);
if (FAILED(hr)) return hr;
break;
}
default: {
TRACE_(dmfile)(": unknown (skipping)\n");
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
break;
}
default: {
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
} while (ListCount[0] < ListSize[0]);
return S_OK;
}
示例4: MSI_RecordReadStream
UINT MSI_RecordReadStream(MSIRECORD *rec, UINT iField, char *buf, LPDWORD sz)
{
ULONG count;
HRESULT r;
IStream *stm;
TRACE("%p %d %p %p\n", rec, iField, buf, sz);
if( !sz )
return ERROR_INVALID_PARAMETER;
if( iField > rec->count)
return ERROR_INVALID_PARAMETER;
if ( rec->fields[iField].type == MSIFIELD_NULL )
{
*sz = 0;
return ERROR_INVALID_DATA;
}
if( rec->fields[iField].type != MSIFIELD_STREAM )
return ERROR_INVALID_DATATYPE;
stm = rec->fields[iField].u.stream;
if( !stm )
return ERROR_INVALID_PARAMETER;
/* if there's no buffer pointer, calculate the length to the end */
if( !buf )
{
LARGE_INTEGER ofs;
ULARGE_INTEGER end, cur;
ofs.QuadPart = cur.QuadPart = 0;
end.QuadPart = 0;
IStream_Seek( stm, ofs, STREAM_SEEK_SET, &cur );
IStream_Seek( stm, ofs, STREAM_SEEK_END, &end );
ofs.QuadPart = cur.QuadPart;
IStream_Seek( stm, ofs, STREAM_SEEK_SET, &cur );
*sz = end.QuadPart - cur.QuadPart;
return ERROR_SUCCESS;
}
/* read the data */
count = 0;
r = IStream_Read( stm, buf, *sz, &count );
if( FAILED( r ) )
{
*sz = 0;
return ERROR_FUNCTION_FAILED;
}
*sz = count;
return ERROR_SUCCESS;
}
示例5: test_copyto
static void test_copyto(void)
{
IStream *pStream, *pStream2;
HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
static const char szHello[] = "Hello";
ULARGE_INTEGER cb;
static const char *methods_copyto[] =
{
"TestStream_Write",
NULL
};
ULONG written;
ULARGE_INTEGER ullRead;
ULARGE_INTEGER ullWritten;
ULARGE_INTEGER libNewPosition;
static const LARGE_INTEGER llZero;
char buffer[15];
ok_ole_success(hr, "CreateStreamOnHGlobal");
expected_method_list = methods_copyto;
hr = IStream_Write(pStream, szHello, sizeof(szHello), &written);
ok_ole_success(hr, "IStream_Write");
ok(written == sizeof(szHello), "only %d bytes written\n", written);
hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
ok_ole_success(hr, "IStream_Seek");
cb.QuadPart = sizeof(szHello);
hr = IStream_CopyTo(pStream, &Test_Stream, cb, &ullRead, &ullWritten);
ok(ullWritten.QuadPart == 5, "ullWritten was %d instead\n", (ULONG)ullWritten.QuadPart);
ok(ullRead.QuadPart == sizeof(szHello), "only %d bytes read\n", (ULONG)ullRead.QuadPart);
ok_ole_success(hr, "IStream_CopyTo");
ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list);
hr = IStream_Clone(pStream, &pStream2);
ok_ole_success(hr, "IStream_Clone");
hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_CUR, &libNewPosition);
ok_ole_success(hr, "IStream_Seek");
ok(libNewPosition.QuadPart == sizeof(szHello), "libNewPosition wasn't set correctly for the cloned stream\n");
hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_SET, NULL);
ok_ole_success(hr, "IStream_Seek");
hr = IStream_Read(pStream2, buffer, sizeof(buffer), NULL);
ok_ole_success(hr, "IStream_Read");
ok(!strcmp(buffer, szHello), "read data \"%s\" didn't match originally written data\n", buffer);
IStream_Release(pStream2);
IStream_Release(pStream);
}
示例6: test_pic
static void
test_pic(const unsigned char *imgdata, unsigned int imgsize)
{
LPSTREAM stream;
HGLOBAL hglob;
LPBYTE data;
HRESULT hres;
LARGE_INTEGER seekto;
ULARGE_INTEGER newpos1;
/* Let the fun begin */
hglob = GlobalAlloc (0, imgsize);
data = GlobalLock (hglob);
memcpy(data, imgdata, imgsize);
hres = CreateStreamOnHGlobal (hglob, FALSE, &stream);
ok (hres == S_OK, "createstreamonhglobal failed? doubt it... hres 0x%08lx\n", hres);
memset(&seekto,0,sizeof(seekto));
hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1);
ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres);
test_pic_with_stream(stream, imgsize);
/* again with Non Statable and Non Seekable stream */
stream = (LPSTREAM)NoStatStreamImpl_Construct(hglob);
test_pic_with_stream(stream, 0);
}
示例7: SHIsEmptyStream
/*************************************************************************
* @ [SHLWAPI.166]
*
* Determine if a stream has 0 length.
*
* PARAMS
* lpStream [I] IStream object
*
* RETURNS
* TRUE: If the stream has 0 length
* FALSE: Otherwise.
*/
BOOL WINAPI SHIsEmptyStream(IStream *lpStream)
{
STATSTG statstg;
BOOL bRet = TRUE;
TRACE("(%p)\n", lpStream);
memset(&statstg, 0, sizeof(statstg));
if(SUCCEEDED(IStream_Stat(lpStream, &statstg, 1)))
{
if(statstg.cbSize.QuadPart)
bRet = FALSE; /* Non-Zero */
}
else
{
DWORD dwDummy;
/* Try to read from the stream */
if(SUCCEEDED(SHIStream_Read(lpStream, &dwDummy, sizeof(dwDummy))))
{
LARGE_INTEGER zero;
zero.QuadPart = 0;
IStream_Seek(lpStream, zero, 0, NULL);
bRet = FALSE; /* Non-Zero */
}
}
return bRet;
}
示例8: IStream_Reset
/*************************************************************************
* @ [SHLWAPI.213]
*
* Seek to the start of a stream.
*
* PARAMS
* lpStream [I] IStream object
*
* RETURNS
* Success: S_OK. The current position within the stream is updated
* Failure: An HRESULT error code.
*/
HRESULT WINAPI IStream_Reset(IStream *lpStream)
{
LARGE_INTEGER zero;
TRACE("(%p)\n", lpStream);
zero.QuadPart = 0;
return IStream_Seek(lpStream, zero, 0, NULL);
}
示例9: navigate_history
static HRESULT navigate_history(DocHost *This, unsigned travellog_pos)
{
IPersistHistory *persist_history;
travellog_entry_t *entry;
LARGE_INTEGER li;
HRESULT hres;
if(!This->doc_navigate) {
FIXME("unsupported doc_navigate FALSE\n");
return E_NOTIMPL;
}
This->travellog.loading_pos = travellog_pos;
entry = This->travellog.log + This->travellog.loading_pos;
if(!entry->stream)
return async_doc_navigate(This, entry->url, NULL, NULL, 0, FALSE);
hres = IUnknown_QueryInterface(This->document, &IID_IPersistHistory, (void**)&persist_history);
if(FAILED(hres))
return hres;
li.QuadPart = 0;
IStream_Seek(entry->stream, li, STREAM_SEEK_SET, NULL);
hres = IPersistHistory_LoadHistory(persist_history, entry->stream, NULL);
IPersistHistory_Release(persist_history);
return hres;
}
示例10: IDirectMusicLoaderGenericStream_IStream_Seek
static HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Seek (LPSTREAM iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, 0x%08llX, %s, %p): redirecting to low-level stream\n", This, dlibMove.QuadPart, resolve_STREAM_SEEK(dwOrigin), plibNewPosition);
if (!This->pStream)
return E_FAIL;
return IStream_Seek (This->pStream, dlibMove, dwOrigin, plibNewPosition);
}
示例11: IWICStreamImpl_Seek
static HRESULT WINAPI IWICStreamImpl_Seek(IWICStream *iface,
LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
IWICStreamImpl *This = impl_from_IWICStream(iface);
TRACE("(%p): relay\n", This);
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
return IStream_Seek(This->pStream, dlibMove, dwOrigin, plibNewPosition);
}
示例12: gdip_save_bitmap_to_callback
static gboolean
gdip_save_bitmap_to_callback (GpBitmap *bitmap,
const CLSID *format,
const EncoderParameters *encoder_params,
GdkPixbufSaveFunc save_func,
gpointer user_data,
GError **error)
{
HRESULT hr;
IStream *streamOut = NULL;
gboolean success = FALSE;
guint64 zero = 0;
GpStatus status;
hr = CreateStreamOnHGlobal (NULL, TRUE, &streamOut);
if (!SUCCEEDED (hr)) {
gdip_set_error_from_hresult (error, GDK_PIXBUF_ERROR_FAILED, hr, _("Could not create stream: %s"));
return FALSE;
}
status = GdipSaveImageToStream ((GpImage *)bitmap, streamOut, format, encoder_params);
if (Ok != status) {
gdip_set_error_from_gpstatus (error, GDK_PIXBUF_ERROR_FAILED, status);
IStream_Release (streamOut);
return FALSE;
}
/* seek back to the beginning of the stream */
hr = IStream_Seek (streamOut, *(LARGE_INTEGER *)&zero, STREAM_SEEK_SET, NULL);
if (!SUCCEEDED (hr)) {
gdip_set_error_from_hresult (error, GDK_PIXBUF_ERROR_FAILED, hr, _("Could not seek stream: %s"));
IStream_Release (streamOut);
return FALSE;
}
for (;;) {
char buffer[LOAD_BUFFER_SIZE];
ULONG nread;
hr = IStream_Read (streamOut, buffer, sizeof(buffer), &nread);
if (!SUCCEEDED (hr))
{
gdip_set_error_from_hresult (error, GDK_PIXBUF_ERROR_FAILED, hr, _("Could not read from stream: %s"));
break;
}
else if (0 == nread) {
success = TRUE; /* EOF */
break;
}
else if (!(*save_func) (buffer, nread, error, user_data))
break;
}
IStream_Release (streamOut);
return success;
}
示例13: IDirectMusicSegTriggerTrack_IPersistStream_Load
static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
DMUS_PRIVATE_CHUNK Chunk;
LARGE_INTEGER liMove;
HRESULT hr;
TRACE("(%p, %p): Loading\n", This, pStm);
#if 1
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case FOURCC_LIST: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGTRACK_LIST: {
TRACE_(dmfile)(": segment trigger track list\n");
hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (iface, &Chunk, pStm);
if (FAILED(hr)) return hr;
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
return E_FAIL;
}
}
TRACE_(dmfile)(": reading finished\n");
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
return E_FAIL;
}
}
#endif
return S_OK;
}
示例14: BmpFrameDecode_ReadUncompressed
static HRESULT BmpFrameDecode_ReadUncompressed(BmpFrameDecode* This)
{
UINT bytesperrow;
UINT width, height;
UINT datasize;
int bottomup;
HRESULT hr;
LARGE_INTEGER offbits;
ULONG bytesread;
if (This->bih.bV5Size == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER *bch = (BITMAPCOREHEADER*)&This->bih;
width = bch->bcWidth;
height = bch->bcHeight;
bottomup = 1;
}
else
{
width = This->bih.bV5Width;
height = abs(This->bih.bV5Height);
bottomup = (This->bih.bV5Height > 0);
}
/* row sizes in BMP files must be divisible by 4 bytes */
bytesperrow = (((width * This->bitsperpixel)+31)/32)*4;
datasize = bytesperrow * height;
This->imagedata = HeapAlloc(GetProcessHeap(), 0, datasize);
if (!This->imagedata) return E_OUTOFMEMORY;
offbits.QuadPart = This->bfh.bfOffBits;
hr = IStream_Seek(This->stream, offbits, STREAM_SEEK_SET, NULL);
if (FAILED(hr)) goto fail;
hr = IStream_Read(This->stream, This->imagedata, datasize, &bytesread);
if (FAILED(hr) || bytesread != datasize) goto fail;
if (bottomup)
{
This->imagedatastart = This->imagedata + (height-1) * bytesperrow;
This->stride = -bytesperrow;
}
else
{
This->imagedatastart = This->imagedata;
This->stride = bytesperrow;
}
return S_OK;
fail:
HeapFree(GetProcessHeap(), 0, This->imagedata);
This->imagedata = NULL;
if (SUCCEEDED(hr)) hr = E_FAIL;
return hr;
}
示例15: IDirectMusicBandImpl_IPersistStream_Load
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
DMUS_PRIVATE_CHUNK Chunk;
LARGE_INTEGER liMove;
HRESULT hr;
TRACE("(%p,%p): loading\n", This, pStm);
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case FOURCC_RIFF: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_BAND_FORM: {
TRACE_(dmfile)(": Band form\n");
hr = IDirectMusicBandImpl_IPersistStream_ParseBandForm (iface, &Chunk, pStm);
if (FAILED(hr)) return hr;
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
return E_FAIL;
}
}
TRACE_(dmfile)(": reading finished\n");
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
return E_FAIL;
}
}
return S_OK;
}