# OleDoAutoConvert

Automatically converts an object to a new class if automatic conversion for that object class is set in the registry.

WINOLEAPI OleDoAutoConvert(

IStorage * pStg, | //Pointer to storage object to be converted
LPCLSID pClsidNew | //Pointer to new CLSID of converted object
); |

Parameters

pStg
  [in] Pointer to the IStorage interface on the storage object to be converted.
pClsidNew
  [out] Pointserto the new CLSID for the object being converted. If there was no automatic conversion, this may be the same as the original class.

Return Values

This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:

S_OK
  No conversion is needed or a conversion was successfully completed.
REGDB_E_KEYMISSING
  The function cannot read a key from the registry.

This function can also return any of the error values returned by the OleGetAutoConvert function. When accessing storage and stream objects, see the IStorage::OpenStorage and IStorage::OpenStream methods for possible errors. When it is not possible to determine the existing CLSID or when it is not possible to update the storage object with new information, see the IStream interface for other error return values.

Remarks

The OleDoAutoConvert function automatically converts an object if automatic conversion has previously been specified in the registry by the OleSetAutoConvert function. Object conversion means that the object is permanently associated with a new CLSID. Automatic conversion is typically specified by the setup program for a new version of an object application, so that objects created by its older versions can be automatically updated.

A container application that supports object conversion should call OleDoAutoConvert each time it loads an object. If the container uses the OleLoad helper function, it need not call OleDoAutoConvert explicitly because OleLoad calls it internally.

OleDoAutoConvert first determines whether any conversion is required by calling the OleGetAutoConvert function, which, if no conversion is required, returns S_OK. If the object requires conversion, OleDoAutoConvert modifies and converts the storage object by activating the new object application. The new object application reads the existing data format, but saves the object in the new native format for the object application.

If the object to be automatically converted is an OLE 1 object, the ItemName string is stored in a stream called “\1Ole10ItemName.” If this stream does not exist, the object’s item name is NULL.

The storage object must be in the unloaded state when OleDoAutoConvert is called.

See Also

OleSetAutoConvert