OleCreate function (ole.h)

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.

Syntax

OLESTATUS OleCreate(
  LPCSTR        unnamedParam1,
  LPOLECLIENT   unnamedParam2,
  LPCSTR        unnamedParam3,
  LHCLIENTDOC   unnamedParam4,
  LPCSTR        unnamedParam5,
  LPOLEOBJECT   *unnamedParam6,
  OLEOPT_RENDER unnamedParam7,
  OLECLIPFORMAT unnamedParam8
);

Parameters

unnamedParam1

TBD

unnamedParam2

TBD

unnamedParam3

TBD

unnamedParam4

TBD

unnamedParam5

TBD

unnamedParam6

TBD

unnamedParam7

TBD

unnamedParam8

TBD

Return value

This function returns S_OK on success and supports the standard return value E_OUTOFMEMORY.

Return code Description
E_OUTOFMEMORY
Insufficient memory for the operation.

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 function or IOleObject::DoVerb to show the object for initial editing.

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 after the return of OleCreate and before the object is run. If renderopt is OLERENDER_DRAW or OLERENDER_FORMAT, OleCreate requires that the object support the IOleCache interface. There is no such requirement for any other value of renderopt.

If pClientSite is non-NULL, OleCreate calls IOleObject::SetClientSite through the pClientSite pointer. IOleClientSite is the primary interface by which an object requests services from its container. If pClientSite is NULL, you must make a specific call to IOleObject::SetClientSite before attempting any operations.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header ole.h (include Ole2.h)
Library Ole32.lib
DLL Ole32.dll

See also

FORMATETC

IOleClientSite

IOleObject

OLERENDER