本文整理汇总了C++中LPSTREAM::Seek方法的典型用法代码示例。如果您正苦于以下问题:C++ LPSTREAM::Seek方法的具体用法?C++ LPSTREAM::Seek怎么用?C++ LPSTREAM::Seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPSTREAM
的用法示例。
在下文中一共展示了LPSTREAM::Seek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
FARINTERNAL UtDIBFileStmToPBrushNativeStm
(LPSTREAM pstmDIBFile, LPSTREAM pstmPBrush)
{
BITMAPFILEHEADER bfh;
HRESULT error;
if (error = pstmDIBFile->Read(&bfh, sizeof(bfh), 0))
return error;
// seek to the begining of the stream
LARGE_INTEGER large_int;
LISet32( large_int, 0);
if (error = pstmDIBFile->Seek(large_int, STREAM_SEEK_SET, 0))
return error;
if (error = pstmPBrush->Write(&(bfh.bfSize), sizeof(DWORD), 0))
return error;
ULARGE_INTEGER ularge_int;
ULISet32(ularge_int, bfh.bfSize);
if ((error = pstmDIBFile->CopyTo(pstmPBrush, ularge_int,
NULL, NULL)) == NOERROR)
StSetSize(pstmPBrush, 0, TRUE);
return error;
}
示例2: _AfxGetClassIDFromStreamedPropset
BOOL AFXAPI _AfxGetClassIDFromStreamedPropset(LPCLSID lpClsid, LPSTREAM lpStream)
{
BOOL bSuccess = FALSE;
ULARGE_INTEGER uliSave;
LARGE_INTEGER liClsidOffset;
LISet32(liClsidOffset, 8);
if (SUCCEEDED(lpStream->Seek(_afxLargeZero, STREAM_SEEK_CUR, &uliSave)))
{
if (SUCCEEDED(lpStream->Seek(liClsidOffset, STREAM_SEEK_CUR, NULL)) &&
SUCCEEDED(lpStream->Read(lpClsid, sizeof(CLSID), NULL)))
{
bSuccess = TRUE;
}
lpStream->Seek(*(LARGE_INTEGER*)&uliSave, STREAM_SEEK_SET, NULL);
}
return bSuccess;
}
示例3: _AfxSaveStreamDataAsBlobProp
BOOL AFXAPI _AfxSaveStreamDataAsBlobProp(LPSTREAM pstm, CPropertySection& psec,
DWORD dwPropID, DWORD dwType)
{
BOOL bSuccess = FALSE;
ULARGE_INTEGER uliStart;
ULARGE_INTEGER uliEnd;
// Note: Stream length must fit in a DWORD.
if (SUCCEEDED(pstm->Seek(_afxLargeZero, STREAM_SEEK_CUR, &uliStart)) &&
SUCCEEDED(pstm->Seek(_afxLargeZero, STREAM_SEEK_END, &uliEnd)) &&
SUCCEEDED(pstm->Seek(*(LARGE_INTEGER*)&uliStart, STREAM_SEEK_SET,
NULL)))
{
DWORD cb = uliEnd.LowPart - uliStart.LowPart;
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE,
cb + (DWORD)sizeof(cb));
if (hGlobal != NULL)
{
LPBYTE pbData = (LPBYTE)GlobalLock(hGlobal);
if (pbData != NULL)
{
*(DWORD*)pbData = cb;
if (SUCCEEDED(pstm->Read(pbData + (DWORD)sizeof(DWORD), cb,
NULL)))
{
bSuccess = psec.Set(dwPropID, pbData, dwType);
}
GlobalUnlock(hGlobal);
}
GlobalFree(hGlobal);
}
}
return bSuccess;
}
示例4: _AfxInitStreamDataFromBlobProp
BOOL AFXAPI _AfxInitStreamDataFromBlobProp(LPSTREAM pstm, CProperty* pprop)
{
BOOL bSuccess = FALSE;
ULONG cb;
BYTE* pbData = (BYTE*)(pprop->Get(&cb));
if (pbData != NULL)
{
// Put the data into the stream, then seek back to start of data.
LARGE_INTEGER liOffset;
liOffset.LowPart = -(LONG)cb;
liOffset.HighPart = -1;
if (SUCCEEDED(pstm->Write(pbData + sizeof(ULONG), cb, NULL)) &&
SUCCEEDED(pstm->Seek(liOffset, STREAM_SEEK_CUR, NULL)))
{
bSuccess = TRUE;
}
}
return bSuccess;
}
示例5: _tmain
int _tmain(int argc, wchar_t* argv[])
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
if (argc != 4) {
wprintf(L"Usage: %s outfile.jpg(or - for stdout) WxH JPEG_quality(0-100)\n", argv[0]);
return 1;
}
int outWidth = 0, outHeight = 0;
swscanf(argv[2], L"%dx%d", &outWidth, &outHeight);
ULONG jpegQuality = 0;
swscanf(argv[3], L"%d", &jpegQuality);
BOOL useStdout = wcscmp(L"-", argv[1]) == 0;
HWND desktop = GetDesktopWindow();
HDC desktopdc = GetDC(desktop);
HDC mydc = CreateCompatibleDC(desktopdc);
int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);
if (!outWidth || !outHeight) {
outWidth = width;
outHeight = height;
}
HBITMAP mybmp = CreateCompatibleBitmap(desktopdc, outWidth, outHeight);
HBITMAP oldbmp = (HBITMAP)SelectObject(mydc, mybmp);
//BitBlt(mydc,0,0,width,height,desktopdc,0,0, SRCCOPY|CAPTUREBLT);
StretchBlt(mydc, 0, 0, outWidth, outHeight, desktopdc, 0, 0, width, height, SRCCOPY|CAPTUREBLT);
SelectObject(mydc, oldbmp);
const wchar_t* filename = argv[1];
EncoderParameters encoderParameters;
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
encoderParameters.Parameter[0].Value = &jpegQuality;
LPSTREAM lpStream = NULL;
CreateStreamOnHGlobal(NULL, TRUE, &lpStream);
Bitmap* b = Bitmap::FromHBITMAP(mybmp, NULL);
CLSID encoderClsid;
Status stat = GenericError;
if (b && GetEncoderClsid(L"image/jpeg", &encoderClsid) != -1) {
if (useStdout)
stat = b->Save(lpStream, &encoderClsid, &encoderParameters);
else
stat = b->Save(filename, &encoderClsid, &encoderParameters);
}
if (useStdout) {
ULARGE_INTEGER pos, newpos;
LARGE_INTEGER seek;
ULONG read;
seek.QuadPart = 0L;
lpStream->Seek(seek, STREAM_SEEK_CUR, &pos);
lpStream->Seek(seek, STREAM_SEEK_SET, &newpos);
void *buf = malloc(pos.QuadPart);
lpStream->Read(buf, pos.QuadPart, &read);
_setmode(_fileno(stdout), _O_BINARY);
fwrite(buf, 1, pos.QuadPart, stdout);
}
if (b)
delete b;
// cleanup
GdiplusShutdown(gdiplusToken);
ReleaseDC(desktop, desktopdc);
DeleteObject(mybmp);
DeleteDC(mydc);
return !(stat == Ok);
}
示例6: _AfxSaveObjectInPropset
BOOL AFXAPI _AfxSaveObjectInPropset(LPUNKNOWN pUnk, CPropertySection& psec,
DWORD dwPropID)
{
if (pUnk == NULL)
return FALSE;
ASSERT_POINTER(pUnk, IUnknown);
BOOL bSuccess = FALSE;
LPDATAOBJECT pDataObj;
if (SUCCEEDED(pUnk->QueryInterface(IID_IDataObject,
(LPVOID*)&pDataObj)))
{
// Get the persistent propset format from object.
FORMATETC formatEtc;
STGMEDIUM stgMedium;
formatEtc.cfFormat = _AfxGetClipboardFormatPersistPropset();
formatEtc.ptd = NULL;
formatEtc.dwAspect = DVASPECT_CONTENT;
formatEtc.lindex = -1;
formatEtc.tymed = TYMED_ISTREAM;
stgMedium.tymed = TYMED_NULL;
stgMedium.pUnkForRelease = NULL;
if (SUCCEEDED(pDataObj->GetData(&formatEtc, &stgMedium)))
{
if (stgMedium.tymed == TYMED_ISTREAM)
{
LPSTREAM pstm = stgMedium.pstm;
// Seek to start of stream.
if (SUCCEEDED(pstm->Seek(_afxLargeZero, STREAM_SEEK_SET, NULL)))
{
// Create a "blobbed" propset from the stream
bSuccess = _AfxSaveStreamDataAsBlobProp(stgMedium.pstm,
psec, dwPropID, VT_BLOB_PROPSET);
}
}
// Cleanup
ReleaseStgMedium(&stgMedium);
}
pDataObj->Release();
}
LPPERSISTSTREAM pPersStm = NULL;
if ((!bSuccess) &&
SUCCEEDED(pUnk->QueryInterface(IID_IPersistStream,
(LPVOID*)&pPersStm)))
{
// Get the object to save itself into a stream, then store that
// streamed data as a blob.
ASSERT_POINTER(pPersStm, IPersistStream);
LPSTREAM pstm = _AfxCreateMemoryStream();
if (pstm != NULL)
{
if (SUCCEEDED(::OleSaveToStream(pPersStm, pstm)) &&
SUCCEEDED(pstm->Seek(_afxLargeZero, STREAM_SEEK_SET, NULL)))
{
bSuccess = _AfxSaveStreamDataAsBlobProp(pstm, psec,
dwPropID, VT_BLOB);
}
pstm->Release();
}
pPersStm->Release();
}
return bSuccess;
}