本文整理汇总了C++中LPSTREAM::Stat方法的典型用法代码示例。如果您正苦于以下问题:C++ LPSTREAM::Stat方法的具体用法?C++ LPSTREAM::Stat怎么用?C++ LPSTREAM::Stat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPSTREAM
的用法示例。
在下文中一共展示了LPSTREAM::Stat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
HRESULT STDMETHODCALLTYPE CXMLDocument::Load(/* [in] */ LPSTREAM pStm)
{
if (pStm == NULL)
{
return E_INVALIDARG;
}
// Load the XML from the stream
STATSTG statstg;
pStm->Stat(&statstg, STATFLAG_NONAME);
ULONG cbBufSize = statstg.cbSize.LowPart;
char *pBuffer = new char[cbBufSize];
if (pBuffer == NULL)
{
return E_OUTOFMEMORY;
}
memset(pBuffer, 0, cbBufSize);
pStm->Read(pBuffer, cbBufSize, NULL);
m_spRoot.Release();
ParseExpat(pBuffer, cbBufSize, (IXMLDocument *) this, &m_spRoot);
delete []pBuffer;
m_nReadyState = READYSTATE_LOADED;
return S_OK;
}
示例2: 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;
}
示例3: GetLargeStringProperty
BOOL CMapiApi::GetLargeStringProperty( LPMAPIPROP pProp, ULONG tag, nsCString& val)
{
LPSTREAM lpStream;
HRESULT hr = pProp->OpenProperty( tag, &IID_IStream, 0, 0, (LPUNKNOWN *)&lpStream);
if (HR_FAILED( hr))
return( FALSE);
STATSTG st;
BOOL bResult = TRUE;
hr = lpStream->Stat( &st, STATFLAG_NONAME);
if (HR_FAILED( hr))
bResult = FALSE;
else {
if (!st.cbSize.QuadPart)
st.cbSize.QuadPart = 1;
char *pVal = new char[ (int) st.cbSize.QuadPart + 1];
// val.SetCapacity( (int) st.cbSize.QuadPart);
if (pVal) {
ULONG sz;
hr = lpStream->Read( pVal, (ULONG) st.cbSize.QuadPart, &sz);
if (HR_FAILED( hr)) {
bResult = FALSE;
*pVal = 0;
sz = 0;
}
else
pVal[(int) st.cbSize.QuadPart] = 0;
val = pVal;
delete [] pVal;
}
else
bResult = FALSE;
}
lpStream->Release();
return( bResult);
}
示例4: LoadStream
HRESULT STDMETHODCALLTYPE TinySmiley::LoadStream(LPSTREAM pStm)
{
if (!pStm) return S_FALSE;
STATSTG pstatstg;
if (FAILED(pStm->Stat(&pstatstg, 0)))
{
return S_FALSE;
}
INT comp = 0;
BYTE* pData = NULL;
//获得字节流大小
BYTE* pv = new BYTE[(UINT)pstatstg.cbSize.QuadPart];
if (!pv) return S_FALSE;
ULONG bytesSaved = 0;
if (FAILED(pStm->Read(pv, (LONG)pstatstg.cbSize.QuadPart, &bytesSaved)))
{
goto error;
}
pData = stbi_load_from_memory_ex(pv, (INT)pstatstg.cbSize.QuadPart, &m_cx, &m_cy, &comp, 4, &m_count);
SAFE_DELETE_ARRAY(pv);
if (!pData)
{
goto error;
}
if (m_count == 1)
{
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = m_cx;
bmi.bmiHeader.biHeight = -m_cy;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = m_cx * m_cy * 4;
BYTE* pvBits = NULL;
HBITMAP hBitmap = ::CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&pvBits, NULL, 0);
if (hBitmap)
{
for (INT i = 0; i < m_cx * m_cy; i++)
{
pvBits[i * 4 + 3] = pData[i * 4 + 3];
if (pvBits[i * 4 + 3] < 255)
{
pvBits[i * 4] = (BYTE)(DWORD(pData[i * 4 + 2])*pData[i * 4 + 3] / 255);//B
pvBits[i * 4 + 1] = (BYTE)(DWORD(pData[i * 4 + 1])*pData[i * 4 + 3] / 255);//G
pvBits[i * 4 + 2] = (BYTE)(DWORD(pData[i * 4])*pData[i * 4 + 3] / 255);//R
}
else
{
pvBits[i * 4] = pData[i * 4 + 2];
pvBits[i * 4 + 1] = pData[i * 4 + 1];
pvBits[i * 4 + 2] = pData[i * 4];
}
}
m_images.push_back(hBitmap);
}
}
else
{
BYTE* seek = pData + m_count * 4 * m_cx * m_cy;
for (size_t i = 0; i < m_count; i++)
{
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = m_cx;
bmi.bmiHeader.biHeight = -m_cy;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = m_cx * m_cy * 4;
BYTE* pvBits = NULL;
HBITMAP hBitmap = ::CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&pvBits, NULL, 0);
if (hBitmap)
{
BYTE* ps = pData + i * m_cx * m_cy;
for (INT i = 0; i < m_cx * m_cy; i++)
{
pvBits[i * 4 + 3] = ps[i * 4 + 3];
if (pvBits[i * 4 + 3] < 255)
{
pvBits[i * 4] = (BYTE)(DWORD(ps[i * 4 + 2])*ps[i * 4 + 3] / 255);//B
pvBits[i * 4 + 1] = (BYTE)(DWORD(ps[i * 4 + 1])*ps[i * 4 + 3] / 255);//G
pvBits[i * 4 + 2] = (BYTE)(DWORD(ps[i * 4])*ps[i * 4 + 3] / 255);//R
}
else
{
pvBits[i * 4] = ps[i * 4 + 2];
pvBits[i * 4 + 1] = ps[i * 4 + 1];
pvBits[i * 4 + 2] = ps[i * 4];
}
}
m_images.push_back(hBitmap);
m_delays.push_back(*(UINT*)seek);
seek += sizeof(UINT);
}
}
}
stbi_image_free(pData);
//.........这里部分代码省略.........