Düzenle

Aracılığıyla paylaş


ITypeInfo::CreateInstance method (oaidl.h)

Creates a new instance of a type that describes a component object class (coclass).

Syntax

HRESULT CreateInstance(
  [in]  IUnknown *pUnkOuter,
  [in]  REFIID   riid,
  [out] PVOID    *ppvObj
);

Parameters

[in] pUnkOuter

The controlling IUnknown. If Null, then a stand-alone instance is created. If valid, then an aggregate object is created.

[in] riid

An ID for the interface that the caller will use to communicate with the resulting object.

[out] ppvObj

An instance of the created object.

Return value

Return code Description
S_OK
Success.
E_INVALIDARG
One or more of the arguments is not valid.
E_OUTOFMEMORY
Insufficient memory to complete the operation.
E_NOINTERFACE
OLE could not find an implementation of one or more required interfaces.
 

Additional errors may be returned from GetActiveObject or CoCreateInstance.

Remarks

For types that describe a component object class (coclass), CreateInstance creates a new instance of the class. Normally, CreateInstance calls CoCreateInstance with the type description's GUID. For an Application object, it first calls GetActiveObject. If the application is active, GetActiveObject returns the active object; otherwise, if GetActiveObject fails, CreateInstance calls CoCreateInstance.

Requirements

Requirement Value
Target Platform Windows
Header oaidl.h

See also

ITypeInfo