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

# CoRegisterClassObject(3w)

## NAME

**CoRegisterClassObject** (OLE32.@)

## SYNOPSIS

HRESULT CoRegisterClassObject\
  (\
   REFCLSID  *rclsid*,\
   LPUNKNOWN *pUnk*,\
   DWORD     *dwClsContext*,\
   DWORD     *flags*,\
   LPDWORD   *lpdwRegister*\
  )

## DESCRIPTION

Registers the class object for a given class **ID**. Servers housed in **EXE** files use this method instead of exporting DllGetClassObject to allow other code to connect to their objects.

## PARAMS

*rclsid* **\[In\]**  **CLSID** of the object to register.

*pUnk* **\[In\]**  IUnknown of the object.

*dwClsContext* **\[In\]**  **CLSCTX** *flags* indicating the context in which to run the executable.

*flags* **\[In\]**  **REGCLS** *flags* indicating how connections are made.

*lpdwRegister* **\[In\]**  A unique cookie that can be passed to CoRevokeClassObject.

## RETURNS

**S\_OK** on success, **E\_INVALIDARG** if *lpdwRegister* or *pUnk* are **NULL**, **CO\_E\_OBJISREG** if the object is already registered. We should not return this.

## SEE ALSO

CoRevokeClassObject, CoGetClassObject.

## NOTES

In-process objects are only registered for the current apartment. CoGetClassObject() and **[CoCreateInstance(3w)](/CoCreateInstance/3w.md)** will not return objects registered in other apartments.

## BUGS

**MSDN** claims that multiple interface registrations are legal, but we can't do that with our current implementation.

## IMPLEMENTATION

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

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

Debug channel **"ole"**.
