OleConvertOLESTREAMToIStorage

Converts the specified object from the OLE 1 storage model to an OLE 2 structured storage object without specifying presentation data. This is one of several compatibility functions.

WINOLEAPI OleConvertOLESTREAMToIStorage(
  LPOLESTREAM lpolestream,   //Pointer to the stream where the OLE 1 
                             // storage is written
  IStorage * pstg,           //Pointer to OLE 2 storage object
  const DVTARGETDEVICE * ptd  //Pointer to target device
);
 

Parameters

lpolestream
[in] Pointer to a stream that contains the persistent representation of the object in the OLE 1 storage format.
pstg
[out] Pointer to the IStorage interface on the OLE 2 structured storage object.
ptd
[in] Pointer to the DVTARGETDEVICE structure specifying the target device for which the OLE 1 object is rendered.

Return Values

This function supports the standard return value E_INVALIDARG, as well as the following:

S_OK
The object was successfully converted.
CONVERT10_S_NO_PRESENTATION
The object either has no presentation data or uses native data for its presentation.
DV_E_DVTARGETDEVICE or DV_E_DVTARGETDEVICE_SIZE
Invalid value for ptd.

Remarks

This function converts an OLE 1 object to an OLE 2 structured storage object. You can use this function to update OLE 1 objects to OLE 2 objects when a new version of the object application supports OLE 2.

On entry, the lpolestm parameter should be created and positioned just as it would be for an OleLoadFromStream function call. On exit, the lpolestm parameter is positioned just as it would be on exit from an OleLoadFromStream function, and the pstg parameter contains the uncommitted persistent representation of the OLE 2 storage object.

For OLE 1 objects that use native data for their presentation, the OleConvertOLESTREAMToIStorage function returns CONVERT10_S_NO_PRESENTATION. On receiving this return value, callers should call IOleObject::Update to get the presentation data so it can be written to storage.

Applications that do not use OLE's default caching resources, but do use the conversion resources, can use an alternate function, OleConvertOLESTREAMToIStorageEx, which can specify which presentation data to convert. In the OleConvertOLESTREAMToIStorageEx function, the presentation data read from the OLESTREAM structure is passed out and the newly created OLE 2 storage object does not contain a presentation stream.

The following steps describe the conversion process using OleConvertOLESTREAMToIStorage:

  1. Create a root IStorage object by calling the StgCreateDocfile function(..., &pstg).
  2. Open the OLE 1 file (using OpenFile or another OLE 1 technique).
  3. Using the OLE 1 procedure for reading files, read from the file until an OLE object is encountered.
  4. Allocate an IStorage object from the root IStorage created in step 1:
    pstg->lpVtbl->CreateStorage(...&pStgChild); 
    hRes = OleConvertIStorageToOLESTREAM(polestm, pStgChild); 
    hRes = OleLoad(pStgChild, &IID_IOleObject, pClientSite, ppvObj); 
     
  5. Repeat step 3 until the file is completely read.

QuickInfo

  Windows NT: Use version 3.1 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in ole2.h.
  Import Library: Included as a resource in ole32.dll.

See Also

CoIsOle1Class, OleConvertIStorageToOLESTREAM, OleConvertIStorageToOLESTREAMEx, OleConvertOLESTREAMToIStorageEx, DVTARGETDEVICE structure, STGMEDIUM structure, TYMED enumeration