There may be an easier way, but here is how I did it:
- Use VERSIONABLE_SCHEMA and GetObjectSchema to identify the version. If old version, then
it is stored in OLE 1.0 format. To read this format, first read a WORD and a CString (type
and name info). Next is the OLE data itself (the hard part). Use the following steps:
- Use StgCreateDocfile to create a temporary Compound File.
- Use OleConvertOLESTREAMToIStorage to copy the data to the Compound file, converting to
OLE 2 format.
- Call OleLoad using the IStorage to get an IUnknown pointer, then call QueryInterface to
set the COleClientItem::m_lpObject member, and set m_nDrawAspect to DVASPECT_CONTENT.
- Release the IUnknown pointer and the IStorage pointer
- The OleConvertOLESTREAMToIStorage code requires an OLESTREAM implementation. Copy the
code from MSVC 1.0 MFC code.
This actually works. There are some issues with messing with the schema parameter, and
I have not implemented writing OLE 1/MFC files. Code available on request.
ronjones@xnet.com, Ron Jones, via programmer.tools, 5/9/95