CoGetTreatAsClass

HRESULT CoGetTreatAsClass(clsidOld, pclsidNew)

Return the existing emulation information for a given class. If no emulation entry exists for clsidOld then clsidOld is returned in pclsidNew.

Argument

Type

Description

clsidOld

REFCID

The class for which the emulation information is to be retrieved.

pclsidNew

CLSID *

The place at which to return the class, if any, which emulates clsidOld. clsidOld is returned if there is no such class. pclsidNew may not be NULL.


Return Value

Meaning

S_OK

Success. A new, (possibly) different CLSID is returned through *pclisdNew.

S_FALSE

Success. The class is emulating itself.

CO_E_READREGDB

.

E_UNEXPECTED

An unspecified error occurred.


How the COM Library implements these functions depends upon the structure of the system registry. For example, under Microsoft Windows, COM uses an additional subkey under an object's CLSID key in the form of:


   TreatAs = {<new CLSID>}

When the Windows COM implementation of CoGetClassObject attempts to locate a server for a CLSID, it will always call CoGetTreatAsClass to retrieve the actual CLSID to use. Since CoGetTreatAsClass will return the same CLSID as passed in if no emulation exists, COM doesn't have to do any special case checks for emulation.