Re: ITypeInfo help needed
David Stuart <nospam@example.com> wrote:
Is it possible to use the ITypeInfo (obtained via the IDispatch) of an
interface to determine:
a) the coclass ID (CLSID) of the interface
First, see if the object implements IPersist or IProvideClassInfo. If it
implements IPersist, call GetClassID. If it implements
IProvideClassInfo, call GetClassInto to obtain ITypeInfo object
corresponding to coclass, then call ITypeInfo::GetTypeAttr; the CLSID
will be in TYPEATTR::guid.
Otherwise, there are heuristics that work most of the time. First, call
GetContainingTypeLib (it may not be supported, in which case you are
sadly out of luck). Enumerate all coclasses using GetTypeInfoCount,
GetTypeInfoType, GetTypeInfo. For each coclass, enumerate all
implemented interfaces with GetRefTypeOfImplType and GetRefTypeInfo.
Hopefully, you will find one coclass that implements your interface.
b) any parent interface IDs (IIDs) that this interface extends
Call GetRefTypeOfImplType with an index of -1 (see Remarks section in
the docs for GetRefTypeOfImplType).
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925