4.8.7 Binding to a Member of a Default Nonsource Interface of an Appobject Coclass

This example shows how to bind to a member of a default nonsource interface of an appobject class.

The sample first tries to bind against the name by using the ITypeComp that corresponds to the automation type library. The sample then uses the ITypeInfo reference thus retrieved, corresponding to the coclass definition, to bind against the name again, retrieving the ITypeInfo server that contains the name in its binding context and the element description (a FUNCDESC or a VARDESC) that corresponds to the name passed in.

 INPUT:  A reference to an ITypeLib server and the name of the 
          member to bind against
 OUTPUT: A reference to the ITypeInfo server corresponding to the 
          interface containing the member
  
 CALL ITypeLib::GetTypeComp with pTypeLib and OBTAIN ITypeComp 
    pointer pTLComp
 CALL ITypeComp::Bind with pTLComp and name and OBTAIN ITypeInfo 
    pointer pTIAppObj and DESCKIND value dk1
  
 COMMENT If the name was a member of a default nonsource interface 
          on an appobject coclass the Bind operation will return 
          the coclass ITypeInfo, DESCKIND_IMPLICITAPPOBJ, and a 
          VAR_STATIC VARDESC
  
 IF dk1 = DESCKIND_IMPLICITAPPOBJ THEN
    CALL ITypeInfo::GetTypeComp with pTIAppObj
       and OBTAIN ITypeComp pointer pAppObjComp
  
    COMMENT The Bind operation below will return the default 
          interface ITypeInfo, DESCKIND_VARDESC or DESCKIND_FUNCDESC,
          and a corresponding VARDESC or FUNCDESC
  
    CALL ITypeComp::Bind with pAppObjComp and name
       and OBTAIN ITypeInfo pointer pTIDefItf and DESCKIND value dk2
  
 END IF