本文整理汇总了C++中LPSTREAM::CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C++ LPSTREAM::CopyTo方法的具体用法?C++ LPSTREAM::CopyTo怎么用?C++ LPSTREAM::CopyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPSTREAM
的用法示例。
在下文中一共展示了LPSTREAM::CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dwSize
FARINTERNAL UtPlaceableMFStmToMSDrawNativeStm
(LPSTREAM pstmPMF, LPSTREAM pstmMSDraw)
{
DWORD dwSize; // size of metafile bits excluding the placeable MF header
LONG xExt;
LONG yExt;
WORD wBuf[5]; // dwSize(DWORD), mm(int), xExt(int), yExt(int)
HRESULT error;
if (error = UtGetSizeAndExtentsFromPlaceableMFStm(pstmPMF, &dwSize,
&xExt, &yExt))
return error;
*((DWORD FAR*) wBuf) = dwSize + 3*sizeof(WORD);
wBuf[2] = MM_ANISOTROPIC;
wBuf[3] = (int) xExt;
wBuf[4] = (int) yExt;
if (error = pstmMSDraw->Write(wBuf, sizeof(wBuf), 0))
return error;
ULARGE_INTEGER ularge_int;
ULISet32(ularge_int, dwSize);
if ((error = pstmPMF->CopyTo(pstmMSDraw, ularge_int,
NULL, NULL)) == NOERROR)
StSetSize(pstmMSDraw, 0, TRUE);
return error;
}
示例2:
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;
}
示例3: 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;
}
示例4: if
FARINTERNAL Ut10NativeStmToContentsStm
(LPSTORAGE pstg, REFCLSID rclsid, BOOL fDeleteSrcStm)
{
CLIPFORMAT cfOld;
CLIPFORMAT cfNew;
LPOLESTR lpszUserType = NULL;
HRESULT error;
LPSTREAM pstmSrc = NULL;
LPSTREAM pstmDst = NULL;
if (error = ReadFmtUserTypeStg(pstg, &cfOld, &lpszUserType))
return error;
if (rclsid == CLSID_StaticDib)
cfNew = CF_DIB;
else if (rclsid == CLSID_StaticMetafile)
cfNew = CF_METAFILEPICT;
else {
AssertSz(FALSE, "Internal Error: this routine shouldn't have been called for this class");
return ResultFromScode(E_FAIL);
}
if (cfOld == g_cfPBrush) {
if (cfNew != CF_DIB) {
error = ResultFromScode(DV_E_CLIPFORMAT);
goto errRtn;
}
} else if (cfOld == g_cfMSDraw) {
if (cfNew != CF_METAFILEPICT) {
error = ResultFromScode(DV_E_CLIPFORMAT);
goto errRtn;
}
} else {
// Converted to static object from some class other than PBrush or
// MSDraw. The data must be in a proper format in the CONTENTS
// stream.
return NOERROR;
}
if (error = pstg->OpenStream(OLE10_NATIVE_STREAM, NULL,
(STGM_READ|STGM_SHARE_EXCLUSIVE),
0, &pstmSrc))
goto errRtn;
if (error = OpenOrCreateStream(pstg, OLE_CONTENTS_STREAM, &pstmDst))
goto errRtn;
DWORD dwSize;
if (error = pstmSrc->Read(&dwSize, sizeof(DWORD), NULL))
goto errRtn;
if (cfOld == g_cfMSDraw) {
WORD mfp[3]; // mm, xExt, yExt
if (error = pstmSrc->Read(mfp, sizeof(mfp), NULL))
goto errRtn;
dwSize -= sizeof(mfp);
error = UtMFStmToPlaceableMFStm(pstmSrc, dwSize,
(LONG) mfp[1], (LONG) mfp[2], pstmDst);
} else {
// The PBrush native data format is DIB File format. So all we got to
// do is CopyTo.
ULARGE_INTEGER ularge_int;
ULISet32(ularge_int, dwSize);
if ((error = pstmSrc->CopyTo(pstmDst, ularge_int, NULL,
NULL)) == NOERROR)
StSetSize(pstmDst, 0, TRUE);
}
errRtn:
if (pstmDst)
pstmDst->Release();
if (pstmSrc)
pstmSrc->Release();
if (error == NOERROR) {
error = WriteFmtUserTypeStg(pstg, cfNew, lpszUserType);
if (fDeleteSrcStm)
pstg->DestroyElement(OLE10_NATIVE_STREAM);
} else {
pstg->DestroyElement(OLE_CONTENTS_STREAM);
}
if (lpszUserType)
PubMemFree(lpszUserType);
return error;
}