Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
HRESULT WriteToStream( IStream* pStream );
Return Value
A standard HRESULT value.
Parameters
pStream
[in] A pointer to the IStream interface on a stream.
Remarks
Saves the m_str member to a stream.
Example
//implementation of IDataObject::GetData()
STDMETHODIMP CPolyCtl::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
{
HRESULT hr = S_OK;
if (pformatetcIn->cfFormat == CF_TEXT && pformatetcIn->tymed == TYMED_ISTREAM)
{
IStream *pStm;
//Create an IStream from global memory
HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &pStm);
if (FAILED(hr))
return hr;
//initialize CComBSTR
CComBSTR bstrStr = "Hello World";
//serialize string into stream
//the length followed by actual string is serialized into stream
hr = bstrStr.WriteToStream(pStm);
//pass the IStream pointer back through STGMEDIUM struct
pmedium->tymed = TYMED_ISTREAM;
pmedium->pstm = pStm;
pmedium->pUnkForRelease = NULL;
}
return hr;
}
CComBSTR Overview | Class Members
See Also CComBSTR::ReadFromStream