描述:
如题
解决方案1:
如上,请查MSDN中的CComBSTR类,ReadFromStream和WriteToStream有示例代码,讲的很清楚.
;)
HRESULT WriteToStream(
IStream* pStream
)
--------------------------------------
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);
--------------------------------------------
引自MSDN
BSTR is a pointer to the actual string characters (it is typedefed to be
OLECHAR*), and that's what you write to the stream and read back.
Reference
http://msdn.microsoft.com/library/en-us/stg/stg/istream.asp