STDMETHODIMP StreamOnAsyncReader::Clone(IStream **ppstm) { IStreamPtr pClone = new StreamOnAsyncReader(m_pReader, m_llPosition); *ppstm = pClone.Detach(); return S_OK; }
HRESULT CAdminPageThreadWnd::PostAdminPage(IAGCEvent* pEvent, UINT message) { // Persist the event object into a stream IStreamPtr spStm; HRESULT hr = CreateStreamOnHGlobal(NULL, true, &spStm); if (FAILED(hr)) return hr; IPersistStreamPtr spPersist(pEvent); if (NULL == spPersist) return E_NOINTERFACE; if (FAILED(hr = spPersist->Save(spStm, false))) return hr; // Post the stream to the worker thread window PostMessage(message, reinterpret_cast<WPARAM>(spStm.Detach()), NULL); return S_OK; }
STDMETHODIMP CPigMissionParams::GetData(IStream** ppstm) { // Initialize the [out] parameter CLEAROUT(ppstm, (IStream*)NULL); // Create a stream on global IStreamPtr spstm; RETURN_FAILED(CreateStreamOnHGlobal(NULL, true, &spstm)); // Write the size of the data structure to the stream UINT cb = sizeof(m_mp); RETURN_FAILED(spstm->Write(&cb, sizeof(cb), NULL)); // Write the data structure to the stream RETURN_FAILED(spstm->Write(&m_mp, cb, NULL)); // Detach the interface to the [out] parameter *ppstm = spstm.Detach(); // Indicate success return S_OK; }