4.8.3 Enumerating on All Enumerations in a Type Library

This example illustrates how to get all enumerations in a type library, and the value represented by each member within the enumeration.

 INPUT: Reference to the ITypeLib server corresponding to the Automation Server
  
 CALL ITypeLib::GetTypeInfoCount and OBTAIN pcTInfo
 COMMENT see Section 3.11.4.1 for information on pcTInfo
  
 FOR X = 0 to pctInfo -1
     CALL ITypeLib::GetTypeInfoType with X and OBTAIN pTKind
     COMMENT see Section 3.11.4.3 for more information on pTKind
  
     IF ptKind = TYPEKIND::TKIND_ENUM THEN
         CALL ITypeLib::GetTypeInfo with X and OBTAIN ITypeInfo pointer
  
         CALL ITypeInfo::GetDocumentation(MEMBERID_NIL, 1, &BstrName, NULL, NULL, NULL)
         PRINT Name of the Enumeration is BstrName
  
         CALL ITypeInfo::GetTypeAttr and OBTAIN TYPEATTR pointer
         FOR Y = 0 to TYPEATTR::cVars -1
             ITypeInfo::GetVarDesc with Y and OBTAIN VARDESC pointer
             CALL ITypeInfo::GetDocumentation(VARDESC::memid, 1, &BstrName, NULL, NULL,
                  NULL)
             COMMENT BstrName will contain the name of the enumeration member
             PRINT BstrName = 
             SET Z to the constant value from VARDESC::lpvarValue
             COMMENT On most platforms the constant value for enumerations would be in 
                     VARDESC::lpvarValue::intVal
             PRINT Z
         END FOR
     END IF 
  
 END FOR