IUnknown::QueryInterface
on this interface pointer to obtain one of the following: IPersist
, IPersistStream
, IPersistStreamInit
or other IPersist*
interfaces. If you are lucky to get one, then GetClassID
method will get you the CLSID
class identifier (alternate option is IProvideClassInfo
and IProvideClassInfo::GetClassInfo
).
Note that this kind of information does not have to exist. An interface pointer can be valid without having CLSID
on the class implementing it.
UPD. If the main goal is to recognize your own implementation on the provided interface ("Is the provided ICanvasFont
the instance of my own MCanvasFont
class, or it is something different?"), then the easiest yet efficient way is to implement some extra private interface on the class. If your querying it succeeds, then you recognize the instance. Provided no marshaling takes place, you can possibly even static_cast
back to original C++ pointer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…