本文整理汇总了C++中IStream_Write函数的典型用法代码示例。如果您正苦于以下问题:C++ IStream_Write函数的具体用法?C++ IStream_Write怎么用?C++ IStream_Write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IStream_Write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PersistHistory_SaveHistory
static HRESULT WINAPI PersistHistory_SaveHistory(IPersistHistory *iface, IStream *pStream)
{
HTMLDocument *This = impl_from_IPersistHistory(iface);
ULONG len, written;
BSTR display_uri;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, pStream);
if(!This->window || !This->window->uri) {
FIXME("No current URI\n");
return E_FAIL;
}
/* NOTE: The format we store is *not* compatible with native MSHTML. We currently
* store only URI of the page (as a length followed by a string) */
hres = IUri_GetDisplayUri(This->window->uri, &display_uri);
if(FAILED(hres))
return hres;
len = SysStringLen(display_uri);
hres = IStream_Write(pStream, &len, sizeof(len), &written);
if(SUCCEEDED(hres))
hres = IStream_Write(pStream, display_uri, len*sizeof(WCHAR), &written);
SysFreeString(display_uri);
return hres;
}
示例2: ItemMonikerImpl_Save
/******************************************************************************
* ItemMoniker_Save
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
{
ItemMonikerImpl *This = impl_from_IMoniker(iface);
HRESULT res;
CHAR *itemNameA,*itemDelimiterA;
/* data written by this function are : 1) DWORD : size of item delimiter string ('\0' included ) */
/* 2) String (type A): item delimiter string ('\0' included) */
/* 3) DWORD : size of item name string ('\0' included) */
/* 4) String (type A): item name string ('\0' included) */
DWORD nameLength = WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, NULL, 0, NULL, NULL);
DWORD delimiterLength = WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, NULL, 0, NULL, NULL);
itemNameA=HeapAlloc(GetProcessHeap(),0,nameLength);
itemDelimiterA=HeapAlloc(GetProcessHeap(),0,delimiterLength);
WideCharToMultiByte( CP_ACP, 0, This->itemName, -1, itemNameA, nameLength, NULL, NULL);
WideCharToMultiByte( CP_ACP, 0, This->itemDelimiter, -1, itemDelimiterA, delimiterLength, NULL, NULL);
TRACE("%p, %s\n", pStm, fClearDirty ? "TRUE" : "FALSE");
res=IStream_Write(pStm,&delimiterLength,sizeof(DWORD),NULL);
res=IStream_Write(pStm,itemDelimiterA,delimiterLength * sizeof(CHAR),NULL);
res=IStream_Write(pStm,&nameLength,sizeof(DWORD),NULL);
res=IStream_Write(pStm,itemNameA,nameLength * sizeof(CHAR),NULL);
HeapFree(GetProcessHeap(), 0, itemNameA);
HeapFree(GetProcessHeap(), 0, itemDelimiterA);
return res;
}
示例3: CB_Save
static HRESULT CALLBACK CB_Save(LPITEMDATA pInfo, IStream *pStm, LPARAM lp)
{
HRESULT hRes;
ok(lp == 0xdeadbeef, "lp=%ld\n", lp);
hRes = IStream_Write(pStm, &pInfo->iPos, sizeof(INT), NULL);
ok(hRes == S_OK, "hRes=0x%x\n", hRes);
hRes = IStream_Write(pStm, &pInfo->pvData, sizeof(PVOID), NULL);
ok(hRes == S_OK, "hRes=0x%x\n", hRes);
return S_OK;
}
示例4: CB_Save
static HRESULT CALLBACK CB_Save(DPASTREAMINFO *pInfo, IStream *pStm, LPVOID lp)
{
HRESULT hRes;
ok(lp == (LPVOID)0xdeadbeef, "lp=%p\n", lp);
hRes = IStream_Write(pStm, &pInfo->iPos, sizeof(INT), NULL);
expect(S_OK, hRes);
hRes = IStream_Write(pStm, &pInfo->pvItem, sizeof(PVOID), NULL);
expect(S_OK, hRes);
return S_OK;
}
示例5: ClassMoniker_Save
/******************************************************************************
* ClassMoniker_Save
******************************************************************************/
static HRESULT WINAPI ClassMoniker_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
{
ClassMoniker *This = impl_from_IMoniker(iface);
HRESULT hr;
DWORD zero = 0;
TRACE("(%p, %s)\n", pStm, fClearDirty ? "TRUE" : "FALSE");
hr = IStream_Write(pStm, &This->clsid, sizeof(This->clsid), NULL);
if (FAILED(hr)) return hr;
return IStream_Write(pStm, &zero, sizeof(zero), NULL);
}
示例6: FTMarshalImpl_MarshalInterface
static HRESULT WINAPI
FTMarshalImpl_MarshalInterface (LPMARSHAL iface, IStream * pStm, REFIID riid, void *pv,
DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
{
IMarshal *pMarshal = NULL;
HRESULT hres;
TRACE("(%p, %s, %p, 0x%x, %p, 0x%x)\n", pStm, debugstr_guid(riid), pv,
dwDestContext, pvDestContext, mshlflags);
/* if the marshalling happens inside the same process the interface pointer is
copied between the apartments */
if (dwDestContext == MSHCTX_INPROC || dwDestContext == MSHCTX_CROSSCTX) {
void *object;
DWORD constant = 0;
GUID unknown_guid = { 0 };
hres = IUnknown_QueryInterface((IUnknown *)pv, riid, &object);
if (FAILED(hres))
return hres;
/* don't hold a reference to table-weak marshaled interfaces */
if (mshlflags & MSHLFLAGS_TABLEWEAK)
IUnknown_Release((IUnknown *)object);
hres = IStream_Write (pStm, &mshlflags, sizeof (mshlflags), NULL);
if (hres != S_OK) return STG_E_MEDIUMFULL;
hres = IStream_Write (pStm, &object, sizeof (object), NULL);
if (hres != S_OK) return STG_E_MEDIUMFULL;
if (sizeof(object) == sizeof(DWORD))
{
hres = IStream_Write (pStm, &constant, sizeof (constant), NULL);
if (hres != S_OK) return STG_E_MEDIUMFULL;
}
hres = IStream_Write (pStm, &unknown_guid, sizeof (unknown_guid), NULL);
if (hres != S_OK) return STG_E_MEDIUMFULL;
return S_OK;
}
/* use the standard marshaler to handle all other cases */
CoGetStandardMarshal (riid, pv, dwDestContext, pvDestContext, mshlflags, &pMarshal);
hres = IMarshal_MarshalInterface (pMarshal, pStm, riid, pv, dwDestContext, pvDestContext, mshlflags);
IMarshal_Release (pMarshal);
return hres;
}
示例7: AntiMonikerImpl_Save
/******************************************************************************
* AntiMoniker_Save
******************************************************************************/
static HRESULT WINAPI
AntiMonikerImpl_Save(IMoniker* iface,IStream* pStm,BOOL fClearDirty)
{
static const DWORD constant = 1;
/* data written by this function is only a DWORD constant set to 1 ! */
return IStream_Write(pStm,&constant,sizeof(constant),NULL);
}
示例8: CreateSampleFiles
// Creates a set of sample files in the current user's Documents directory to use as items in the
// custom category inserted into the Jump List.
HRESULT CreateSampleFiles()
{
PWSTR pszPathDocuments;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_CREATE, NULL, &pszPathDocuments);
if (SUCCEEDED(hr))
{
for (UINT i = 0; SUCCEEDED(hr) && i < ARRAYSIZE(c_rgpszFiles); i++)
{
WCHAR szPathSample[MAX_PATH];
hr = PathCombine(szPathSample, pszPathDocuments, c_rgpszFiles[i]) ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{
IStream *pstm;
hr = SHCreateStreamOnFileEx(szPathSample, (STGM_WRITE | STGM_FAILIFTHERE), FILE_ATTRIBUTE_NORMAL, TRUE, NULL, &pstm);
if (SUCCEEDED(hr))
{
PCWSTR pszText = L"This is a sample file for the CustomJumpListSample.\r\n";
ULONG cb = (sizeof(pszText[0]) * (lstrlen(pszText) + 1));
hr = IStream_Write(pstm, pszText, cb);
pstm->Release();
}
else if (HRESULT_FROM_WIN32(ERROR_FILE_EXISTS) == hr)
{
// If the file exists, we're ok, we'll just reuse it
hr = S_OK;
}
}
}
CoTaskMemFree(pszPathDocuments);
}
return hr;
}
示例9: XMLView_BindStatusCallback_OnDataAvailable
static HRESULT WINAPI XMLView_BindStatusCallback_OnDataAvailable(
IBindStatusCallback *iface, DWORD grfBSCF, DWORD dwSize,
FORMATETC *pformatetc, STGMEDIUM *pstgmed)
{
BindStatusCallback *This = impl_from_IBindStatusCallback(iface);
char buf[1024];
DWORD size;
HRESULT hres;
TRACE("(%p)->(%x %d %p %p)\n", This, grfBSCF, dwSize, pformatetc, pstgmed);
if(!This->stream)
return E_FAIL;
do {
hres = IStream_Read(pstgmed->u.pstm, buf, sizeof(buf), &size);
IStream_Write(This->stream, buf, size, &size);
} while(hres==S_OK && size);
if(FAILED(hres) && hres!=E_PENDING)
return hres;
if(hres != S_FALSE)
return S_OK;
return handle_xml_load(This);
}
示例10: mxwriter_saxcontent_startDocument
static HRESULT WINAPI mxwriter_saxcontent_startDocument(ISAXContentHandler *iface)
{
mxwriter *This = impl_from_ISAXContentHandler( iface );
TRACE("(%p)\n", This);
/* If properties have been changed since the last "endDocument" call
* we need to reset the output buffer. If we don't the output buffer
* could end up with multiple XML documents in it, plus this seems to
* be how Windows works.
*/
if (This->prop_changed) {
reset_output_buffer(This);
This->prop_changed = FALSE;
}
if (This->props[MXWriter_OmitXmlDecl] == VARIANT_TRUE) return S_OK;
write_prolog_buffer(This);
if (This->dest && This->xml_enc == XmlEncoding_UTF16) {
static const char utf16BOM[] = {0xff,0xfe};
if (This->props[MXWriter_BOM] == VARIANT_TRUE)
/* Windows passes a NULL pointer as the pcbWritten parameter and
* ignores any error codes returned from this Write call.
*/
IStream_Write(This->dest, utf16BOM, sizeof(utf16BOM), NULL);
}
return S_OK;
}
示例11: IcnsEncoder_Commit
static HRESULT WINAPI IcnsEncoder_Commit(IWICBitmapEncoder *iface)
{
IcnsEncoder *This = impl_from_IWICBitmapEncoder(iface);
size_t buffer_size;
HRESULT hr = S_OK;
ULONG byteswritten;
TRACE("(%p)\n", iface);
EnterCriticalSection(&This->lock);
if (!This->any_frame_committed || This->outstanding_commits > 0 || This->committed)
{
hr = WINCODEC_ERR_WRONGSTATE;
goto end;
}
buffer_size = GetHandleSize((Handle)This->icns_family);
hr = IStream_Write(This->stream, *This->icns_family, buffer_size, &byteswritten);
if (FAILED(hr) || byteswritten != buffer_size)
{
WARN("writing file failed, hr = 0x%08X\n", hr);
hr = E_FAIL;
goto end;
}
This->committed = TRUE;
end:
LeaveCriticalSection(&This->lock);
return hr;
}
示例12: PersistStreamInit_Save
static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
BOOL fClearDirty)
{
HTMLDocument *This = impl_from_IPersistStreamInit(iface);
char *str;
DWORD written=0;
HRESULT hres;
TRACE("(%p)->(%p %x)\n", This, pStm, fClearDirty);
hres = get_doc_string(This->doc_node, &str);
if(FAILED(hres))
return hres;
hres = IStream_Write(pStm, str, strlen(str), &written);
if(FAILED(hres))
FIXME("Write failed: %08x\n", hres);
heap_free(str);
if(fClearDirty)
set_dirty(This, VARIANT_FALSE);
return S_OK;
}
示例13: IDirectMusicLoaderGenericStream_IStream_Write
static HRESULT WINAPI IDirectMusicLoaderGenericStream_IStream_Write (LPSTREAM iface, const void* pv, ULONG cb, ULONG* pcbWritten) {
ICOM_THIS_MULTI(IDirectMusicLoaderGenericStream, StreamVtbl, iface);
TRACE_(dmfileraw)("(%p, %p, 0x%08lX, %p): redirecting to low-level stream\n", This, pv, cb, pcbWritten);
if (!This->pStream)
return E_FAIL;
return IStream_Write (This->pStream, pv, cb, pcbWritten);
}
示例14: write_hlink_string
static HRESULT write_hlink_string(IStream *pStm, LPCWSTR str)
{
DWORD len;
HRESULT hr;
TRACE("(%p, %s)\n", pStm, debugstr_w(str));
len = strlenW(str) + 1;
hr = IStream_Write(pStm, &len, sizeof(len), NULL);
if (FAILED(hr)) return hr;
hr = IStream_Write(pStm, str, len * sizeof(WCHAR), NULL);
if (FAILED(hr)) return hr;
return S_OK;
}
示例15: IWICStreamImpl_Write
static HRESULT WINAPI IWICStreamImpl_Write(IWICStream *iface,
void const *pv, ULONG cb, ULONG *pcbWritten)
{
IWICStreamImpl *This = impl_from_IWICStream(iface);
TRACE("(%p): relay\n", This);
if (!This->pStream) return WINCODEC_ERR_NOTINITIALIZED;
return IStream_Write(This->pStream, pv, cb, pcbWritten);
}