CoTreatAsClass

HRESULT CoTreatAsClass(clsidOld, clsidNew)

Establish or cancel an emulation relationship between two classes. When clsidNew is emulating clsidOld, calls to CoGetClassObject with clsidOld will transparently use clsidNew. Thus, for example, creating an object of clsidOld will in fact launch the server for clsidNew and have it create the object instead.

This function does no validation on whether an appropriate registration entries exist for clsidNew.

An emulation is canceled by calling this function with clsidOld equal to the original class and clsidNew set to CLSID_NULL.

Argument

Type

Description

clsidOld

REFCID

The class to be emulated.

clsidNew

REFCID

The class which should emulate clsidOld. This replaces any existing emulation for clsidOld. May be CLSID_NULL, in which case any existing emulation for clsidOld is removed.


Return Value

Meaning

S_OK

Success.

CO_E_CLASSNOTREG

to be described.

CO_E_READREGDB

to be described.

CO_E_WRITEREGDB

to be described.

E_UNEXPECTED

An unspecified error occurred.