How to identify a "default member" in a COM library?

Viewed 164

I'm using the ITypeInfo API to "translate" COM type libraries into "declaration" objects that my application uses.

One of the features of a "declaration" is "attributes" - I'm able to tell when a property "declaration" should have a {name}.VB_UserMemId = -4 attribute (i.e. when it's a _NewEnum non-browsable property; I'm also able to tell when a property is hidden.

What I'm failing to tell, is when a member is the default member for the type. According to the description of FUNCFLAG_FDEFAULTBIND (MSDN):

The function that best represents the object. Only one function in a type information can have this attribute.

...this sounds very very much like what I'm looking for. However among all the members I'm iterating across a handful of type libraries (including the VBA standard library and the entire Excel object model), exactly none have that flag on.

I'm expecting this code to call AddDefaultMemberAttribute for things like Collection.Item, which is the type's default member - but no dice. Am I not checking the correct flag/value?

var attributes = new Attributes();
if (((FUNCFLAGS)memberDescriptor.wFuncFlags) != 0)
{
    if (memberName == "_NewEnum" && ((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FNONBROWSABLE))
    {
        attributes.AddEnumeratorMemberAttribute(memberName);
    }
    else if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN))
    {
        attributes.AddHiddenMemberAttribute(memberName);
    }
    else if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FDEFAULTBIND))
    {
        // bug: none of the 30K+ reflected members have this flag on??
        attributes.AddDefaultMemberAttribute(memberName);
    }
}
1 Answers
Related