本文整理汇总了C++中IStream::Commit方法的典型用法代码示例。如果您正苦于以下问题:C++ IStream::Commit方法的具体用法?C++ IStream::Commit怎么用?C++ IStream::Commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStream
的用法示例。
在下文中一共展示了IStream::Commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetNotes
bool MAPIContact::SetNotes(const String &szNotes, bool bRTF) {
#ifdef _WIN32_WCE
return SetPropertyString(PR_BODY, szNotes);
#else
if(!Contact() || IsNull(szNotes))
return false;
ULONG nLen = (ULONG)szNotes.GetLength();
HRESULT hr = E_FAIL;
LPSTREAM pStream = NULL;
if(bRTF) {
if(Contact()->OpenProperty(PR_RTF_COMPRESSED, &IID_IStream, STGM_CREATE | STGM_WRITE,
MAPI_MODIFY | MAPI_CREATE, (LPUNKNOWN*)&pStream) == S_OK) {
IStream *pUncompressed;
if(WrapCompressedRTFStream(pStream,MAPI_MODIFY, &pUncompressed) == S_OK) {
hr = pUncompressed->Write(szNotes, nLen*sizeof(TCHAR), NULL);
if(pUncompressed->Commit(STGC_DEFAULT)==S_OK)
pStream->Commit(STGC_DEFAULT);
RELEASE(pUncompressed);
}
}
} else {
if(Contact()->OpenProperty(PR_BODY, &IID_IStream, 0, MAPI_MODIFY | MAPI_CREATE,
(LPUNKNOWN*)&pStream) == S_OK)
hr = pStream->Write(szNotes, (nLen+1)*sizeof(TCHAR), NULL);
}
RELEASE(pStream);
return (hr == S_OK);
#endif
}
示例2: LoadDOMDocument
int CSOAPUtil::LoadDOMDocument(char* data, int size, MSXML2::IXMLDOMDocumentPtr xmlDoc)
{
if( data == NULL || xmlDoc == NULL ) {
return ERR_FALSE;
}
IStream* pIStream = NULL;
IPersistStreamInit* pIPStream = NULL;
HRESULT hr = CreateStreamOnHGlobal(NULL,TRUE,&pIStream);
if(FAILED(hr)) {
return ERR_FALSE;
}
hr = pIStream->Write(data,size,NULL);
if(FAILED(hr)) {
pIStream->Release();
pIStream = NULL;
return ERR_FALSE;
}
pIStream->Commit(STGC_OVERWRITE);
LARGE_INTEGER pos = {0, 0};
pIStream->Seek(pos, STREAM_SEEK_SET, NULL);
hr = xmlDoc->QueryInterface(IID_IPersistStreamInit, (void **)&pIPStream);
if(FAILED(hr)) {
pIStream->Release();
pIStream = NULL;
return ERR_FALSE;
}
hr = pIPStream->Load(pIStream);
pIPStream->Release();
pIPStream = NULL;
pIStream->Release();
pIStream = NULL;
if(FAILED(hr)) {
return ERR_FALSE;
} else {
return NO_ERR;
}
}
示例3: EncryptSignMessage
int CExtImpl::EncryptSignMessage(HWND hwnd,
IMessage *pmsg,
RECIPIENTDIALOGSTRUCT *prds,
PGPOptionListRef *pSignOptions)
{
IStream *pstrmBody = 0;
STATSTG StreamStats;
DWORD dwInSize;
UINT nOutSize;
BOOL bExchangeUser = FALSE;
char *pInput;
char *pOutput = NULL;
LPMAPITABLE ptableAttach = 0;
SizedSPropTagArray(1, tagaTable) = {
1, {PR_ATTACH_NUM}};
SRowSet *prAttach = 0;
PGPError nError = kPGPError_NoErr;
HRESULT hr;
char szName[256];
char szFile[256];
UIGetString(szName, sizeof(szName), IDS_LOGNAME);
UIGetString(szFile, sizeof(szFile), IDS_DLL);
pmsg->GetAttachmentTable(0, &ptableAttach);
HrQueryAllRows(ptableAttach, (SPropTagArray *)&tagaTable,
NULL, NULL, 0, &prAttach);
hr = pmsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READ,
0, (IUnknown**)&pstrmBody);
if (FAILED(hr))
{
UIDisplayStringID(hwnd, IDS_E_NOBODY);
ptableAttach->Release();
return kPGPError_ItemNotFound;
}
pstrmBody->Stat(&StreamStats, STATFLAG_NONAME);
dwInSize = StreamStats.cbSize.LowPart;
pInput = (char *) calloc(dwInSize+1, sizeof(char));
if (!pInput)
{
UIDisplayStringID(hwnd, IDS_E_NOMEMORY);
pstrmBody->Release();
ptableAttach->Release();
return kPGPError_OutOfMemory;
}
pstrmBody->Read(pInput, dwInSize, &dwInSize);
pstrmBody->Release();
pInput[dwInSize] = 0;
nError = EncryptSignBuffer(UIGetInstance(), hwnd, _pgpContext,
_tlsContext, szName, szFile, pInput,
dwInSize, prds, NULL, pSignOptions, (VOID ** )&pOutput,
&nOutSize, _bEncrypt, _bSign, FALSE);
if ((dwInSize > 0) && IsntPGPError(nError))
{
LARGE_INTEGER li = {0,0};
ULARGE_INTEGER uli = {1,0};
BOOL fPartied;
pmsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READWRITE,
MAPI_MODIFY, (IUnknown**)&pstrmBody);
pstrmBody->Seek(li, STREAM_SEEK_SET, NULL);
pstrmBody->Write("\0", 1, NULL);
pstrmBody->SetSize(uli);
pstrmBody->Commit(STGC_DEFAULT);
pstrmBody->Release();
RTFSync(pmsg, RTF_SYNC_BODY_CHANGED, &fPartied);
pmsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READWRITE,
MAPI_MODIFY, (IUnknown**)&pstrmBody);
}
if (IsntPGPError(nError))
{
LARGE_INTEGER li = {0,0};
ULARGE_INTEGER uli = {nOutSize + prAttach->cRows, 0};
BOOL fPartied;
pstrmBody->Seek(li, STREAM_SEEK_SET, NULL);
pstrmBody->Write(pOutput, nOutSize, NULL);
pstrmBody->SetSize(uli);
pstrmBody->Commit(STGC_DEFAULT);
pstrmBody->Release();
RTFSync(pmsg, RTF_SYNC_BODY_CHANGED, &fPartied);
PGPFreeData(pOutput);
}
free(pInput);
if (IsntPGPError(nError))
{
hr = pmsg->OpenProperty(PR_BODY_HTML, &IID_IStream, STGM_READWRITE,
MAPI_MODIFY, (IUnknown**)&pstrmBody);
//.........这里部分代码省略.........
示例4: OnRead
//.........这里部分代码省略.........
STGM_READWRITE, MAPI_MODIFY, (IUnknown**)&pstrmBody);
}
else
bGotHTML = TRUE;
if (FAILED(hr))
{
pmsg->Release();
psess->Release();
return S_FALSE;
}
pstrmBody->Stat(&StreamStats, STATFLAG_NONAME);
dwInSize = StreamStats.cbSize.LowPart;
pInput = (char *) calloc(dwInSize+1, sizeof(char));
if (!pInput)
{
UIDisplayStringID(hwnd, IDS_E_NOMEMORY);
pstrmBody->Release();
pmsg->Release();
psess->Release();
return S_FALSE;
}
pstrmBody->Read(pInput, dwInSize, &dwInSize);
pInput[dwInSize] = 0;
if (AutoDecrypt(_memoryMgr))
{
nError = DecryptVerifyBuffer(UIGetInstance(), hwnd,
_pgpContext, _tlsContext, szName,
szFile, pInput, dwInSize,
FALSE, (VOID ** )&pOutput, &nOutSize, &FYEO);
if (IsntPGPError(nError) && (nOutSize > 0) &&
(pOutput != NULL))
{
LARGE_INTEGER li = {0,0};
ULARGE_INTEGER uli = {nOutSize, 0};
BOOL fPartied;
char *szBuffer = NULL;
// Alter only the block of encrypted/signed text
// if this is not HTML
if((FYEO)||(GetSecureViewerPref(_pgpContext)))
{
TempestViewer((void *)_pgpContext,hwnd,
pOutput,nOutSize,FYEO);
}
else
{
szBuffer = (char *) calloc(dwInSize+nOutSize+1,
sizeof(char));
strcpy(szBuffer, pOutput);
if (strlen(szBuffer) > 0)
{
uli.LowPart = strlen(szBuffer);
pstrmBody->Seek(li, STREAM_SEEK_SET, NULL);
pstrmBody->Write(szBuffer, strlen(szBuffer),
NULL);
pstrmBody->SetSize(uli);
pstrmBody->Commit(STGC_DEFAULT);
pstrmBody->Release();
RTFSync(pmsg, RTF_SYNC_BODY_CHANGED,
&fPartied);
}
free(szBuffer);
}
PGPFreeData(pOutput);
}
else
pstrmBody->Release();
}
else
pstrmBody->Release();
free(pInput);
pmsg->Release();
}
psess->Release();
}
break;
case EECONTEXT_READPOSTMESSAGE:
break;
default:
// This way, the function defends itself against unknown future
// variants, as FindREOnNote is less robust than it might be.
return S_FALSE;
}
return S_FALSE;
}