Registers an EXE class object with OLE so that other applications can connect to it. EXE object applications should call CoRegisterClassObject on startup. It can also be used to register internal objects for use by the same EXE or other code (such as DLLs) that the EXE uses.

STDAPI CoRegisterClassObject(

REFCLSID rclsid,
//Class identifier to be registered
IUnknown * pUnk,
//Pointer to the class object
DWORD dwClsContext,
//Context for running executable code
DWORD flags,
//How to connect to the class object
LPDWORD * lpdwRegister
//Pointer to the value returned



Specifies the CLSID registered.


Points to the class object whose availability is being published.


Specifies the context in which the executable code is to be run. For information on these context values, see the CLSCTX enumeration.


Determines how connections are made to the class object. For information on these flags, see the REGCLS enumeration.


Points to the value returned by CoRegisterClassObject that identifies the class object; later used by the CoRevokeClassObject function to revoke the registration.

Return Values


Indicates the class object was registered successfully.


Indicates already registered in the class object table.


Out of memory.


Indicates one or more arguments are invalid.


Indicates an unexpected error occurred.


Only EXE object applications call CoRegisterClassObject. Servers that can create and support more than one kind of object (such as multiple types of embeddable objects) must also register each of class of object it supports. Object handlers or DLL object applications do not call this function; instead, they must implement and export the DllGetClassObject function.

When a multiple-use EXE object application is started, it must create a class object with the IClassFactory interface on it and register it with a call to CoRegisterClassObject. Object applications that support several different object definitions must allocate a different class object for each.

Multiple registrations of the same class object are independent and do not produce an error. Each subsequent registration yields a unique key in lpdwRegister.

Multiple document interface (MDI) applications must register their class objects. Single document interface (SDI) applications must register their class objects only if they can be started by means of the /Embedding switch.

The server for a class object should call CoRevokeClassObject to revoke the class object when all of the following are true:

  • There are no existing instances of the object definition

  • There are no locks on the class object

  • The application providing services to the class object is not under user control (not visible to the user on the display).

After the class object is revoked, when its reference count reaches zero, the class object can be destroyed, allowing the application to exit.

For information on the flags parameter, refer to the REGCLS enumeration.

See Also

CoGetClassObject, CoRevokeClassObject, DllGetClassObject, REGCLS, CLSCTX

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database