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. |
This function creates an embedded object identified by a CLSID. It is typically used to implement a menu item that allows the end user to insert a new object.
WINOLEAPI OleCreate( REFCLSID rclsid, REFIID riid, DWORD renderopt, FORMATETC * pFormatEtc, IOleClientSite * pClientSite, IStorage * pStg, void ** ppvObject );
Parameters
Return Values
This function supports the standard return value E_OUTOFMEMORY, as well as the following:
Value | Description |
---|---|
S_OK | Embedded object created successfully. |
Remarks
Passing into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.
The OleCreatefunction creates a new embedded object, and is typically called to implement the menu item Insert New Object. When OleCreatereturns, the object it has created 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 desired 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 will use 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 the first time the object enters the running state. The caller can add additional 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 any operations.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 2.0 and later | Ole2.h | Ole232.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.