OleCreate
Creates an
embedded object identified by a CLSID. You use it typically to implement the
menu item that allows the end user to insert a new object.
WINOLEAPI OleCreate(
REFCLSID rclsid, |
//CLSID of embedded object to be created |
REFIID riid, |
//Reference to the identifier of the interface used
to communicate with new object |
DWORD renderopt, |
//RENDEROPT value indicating cached capabilities |
FORMATETC
* pFormatEtc, |
//Pointer to a FORMATETC structure |
IOleClientSite * pClientSite, |
//Pointer to request services from the container |
IStorage *
pStg, |
//Pointer to storage for the object |
void ** ppvObject |
//Indirect pointer to new object |
); |
|
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 will communicate with the new object.
renderopt
[in] A value
from the enumeration OLERENDER
pFormatEtc
[in]
Depending on which of the OLERENDER flags is used as the value of renderopt,
pointer to one of the FORMATETC
pClientSite
[in] If you
want OleCreate to call IOleObject::SetClientSite
pStg
[in] Pointer
to an instance of the IStorage
ppvObject
[out] Upon
successful return, indirect pointer to the interface requested in riid
on the newly created object.
Return Values
This function
supports the standard return value E_OUTOFMEMORY, as well as the following:
S_OK
Embedded
object created successfully.
Remarks
The
OleCreate function creates a new embedded object, and is typically called
to implement the menu item Insert New Object. When OleCreate
returns, the object it has created is blank (contains no data), unless renderopt
is OLERENDER_DRAW or OLERENDER_FORMAT, and is loaded. Containers typically then
call the OleRun
The rclsid
parameter 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 OleCreate is used to implement
the Insert Object menu item, the CLSID associated with the selected item is
assigned to the rclsid parameter of OleCreate.
The riid
parameter specifies the interface the client will use to communicate with the
new object. Upon successful return, the ppvObject parameter 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 renderopt and pFormatetc values. When OleCreate
returns, 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::Cache
If pClientSite
is non-NULL, OleCreate calls IOleObject::SetClientSite
See Also