Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function creates an embedded object identified by a CLSID. It is typically used to implement a menu item that allows the user to insert a new object.

Syntax

WINOLEAPI OleCreate( 
  REFCLSID 
rclsid, 
  REFIID 
riid, 
  DWORD 
renderopt, 
  FORMATETC* 
pFormatEtc, 
  IOleClientSite* 
pClientSite, 
  IStorage* 
pStg, 
  void** 
ppvObject
); 

Parameters

rclsid

[in] CLSID of the embedded object that is to be created.

riid

[in] Reference to the identifier of the interface, usually IID_IOleObject(defined in the OLE headers as the interface identifier for IOleObject), through which the caller communicates with the new object.

renderopt

[in] Value from the enumeration OLERENDER, indicating the locally cached drawing capabilities the newly created object is to have. The OLERENDERvalue chosen affects the possible values for the pFormatEtcparameter.

pFormatEtc

[in] Depending on which OLERENDERflag is used as the value of renderopt, this is a pointer to an FORMATETCenumeration value. For restrictions, see the OLERENDERenumeration.

This parameter, along with the renderoptparameter, specifies what the new object can cache initially.

pClientSite

[in] If you want OleCreateto call IOleObject::SetClientSite, pClientSiteis the pointer to the IOleClientSiteinterface on the container.

The value can be NULL, in which case you must specifically call IOleClientSite::SetClientSitebefore attempting operations.

pStg

[in] Pointer to an instance of the IStorageinterface on the storage object.

This parameter cannot be NULL.

ppvObject

[out] Pointer to the pointer variable that receives the interface pointer requested in riid.

Upon successful return, * ppvObjectcontains the requested interface pointer.

Return Value

This function returns S_OK if the embedded object is created.

This function returns E_OUTOFMEMORY if it fails.

Remarks

Passing invalid (and under some circumstances NULL) pointers into this function causes an unexpected termination of the application.

The OleCreatefunction creates an embedded object and is typically called to implement the Insert New Object menu item.

When OleCreatereturns, the object it creates is blank (contains no data), unless renderoptis OLERENDER_DRAW or OLERENDER_FORMAT, and is loaded. Containers typically then call the OleRunfunction or IOleObject::DoVerbto show the object for initial editing.

The rclsidparameter specifies the CLSID of the requested object. CLSIDs of registered objects are stored in the system registry. When an application user selects Insert Object, a selection box allows the user to select the type of object from those in the registry.

When OleCreateis used to implement the Insert Object menu item, the CLSID associated with the selected item is assigned to the rclsidparameter of OleCreate.

The riidparameter specifies the interface the client uses to communicate with the new object. Upon successful return, the ppvObjectparameter holds a pointer to the requested interface.

The created object's cache contains information that allows a presentation of a contained object when the container is opened. Information about what should be cached is passed in the renderoptand pFormatetcvalues.

When OleCreatereturns, the created object's cache is not necessarily filled. Instead, the cache is filled when the object first enters the running state.

The caller can add cache control with a call to IOleCache::Cacheafter the return of OleCreateand before the object is run.

If renderoptis OLERENDER_DRAW or OLERENDER_FORMAT, OleCreaterequires that the object support the IOleCacheinterface. There is no such requirement for any other value of renderopt.

If pClientSiteis non-NULL, OleCreatecalls IOleObject::SetClientSitethrough the pClientSitepointer. IOleClientSiteis the primary interface by which an object requests services from its container.

If pClientSiteis NULL, you must make a specific call to IOleObject::SetClientSitebefore attempting operations.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header ole2.h
Library ole32.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also