---
name: "CoCreateInstance"
section: "3w"
platform: "linux"
package: "libwine-dev"
version: "1.4.1-4"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/CoCreateInstance"
---

# CoCreateInstance(3w)

## NAME

**CoCreateInstance** (OLE32.@)

## SYNOPSIS

HRESULT CoCreateInstance\
  (\
   REFCLSID  *rclsid*,\
   LPUNKNOWN *pUnkOuter*,\
   DWORD     *dwClsContext*,\
   REFIID    *iid*,\
   LPVOID\*   *ppv*\
  )

## DESCRIPTION

Creates an instance of the specified class.

## PARAMS

*rclsid* **\[In\]**  Class Id to create an instance of.

*pUnkOuter* **\[In\]**  Optional outer unknown to allow aggregation with another object.

*dwClsContext* **\[In\]**  Flags to restrict the location of the created instance.

*iid* **\[In\]**  The Id of the interface of the instance to return.

*ppv* **\[Out\]**  On returns, contains a pointer to the specified interface of the instance.

## RETURNS

**Success:** **S\_OK**

**Failure:** **HRESULT** code.

## NOTES

The *dwClsContext* parameter can be one or more of the following: \
\
  CLSCTX\_INPROC\_SERVER - Use an in-process server, such as from a DLL.\
\
  CLSCTX\_INPROC\_HANDLER - Use an in-process object which handles certain functions for an object running in another process.\
\
  CLSCTX\_LOCAL\_SERVER - Connect to an object running in another process.\
\
  CLSCTX\_REMOTE\_SERVER - Connect to an object running on another machine.

Aggregation is the concept of deferring the IUnknown of an object to another object. This allows a separate object to behave as though it was part of the object and to allow this the *pUnkOuter* parameter can be set. Note that not all objects support having an outer of unknown.

## SEE ALSO

CoGetClassObject()

## IMPLEMENTATION

Declared in **"objbase.h"**.

Implemented in **"dlls/ole32/compobj.c"**.

Debug channel **"ole"**.
