10.1. Structured Storage/Compound Files

Microsoft Visual C++/Microsoft Foundation Classes


10.1. Structured Storage/Compound Files

10.1.1. When I upgraded, I could not read my files generated by the old version of MFC. What do I do?

There may be an easier way, but here is how I did it:

  1. 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:
  2. Use StgCreateDocfile to create a temporary Compound File.
  3. Use OleConvertOLESTREAMToIStorage to copy the data to the Compound file, converting to OLE 2 format.
  4. 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.
  5. Release the IUnknown pointer and the IStorage pointer
  6. 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.

[email protected], Ron Jones, via programmer.tools, 5/9/95