Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
Aug 26, 2000



Application Security Testing: An Integral Part of DevOps

GetClasses - Enumerate all the classes defined in a type library

' Return a collection with all creatable classes of
' the type library specified in TypeLibFile.
' Set IncludeNotCreatableClasses = True to include not creatable classes
' (that is, those with Instancing property set to PublicNotCreatable) too.

' Be sure that "TypeLib Information" type library (TlbInf32.tlb)
' is referenced in your VB project.

Function GetClasses(ByVal TypeLibFile As String, _
    Optional ByVal IncludeNotCreatableClasses As Boolean) As Collection
    Dim TLI As New TLIApplication
    Dim TypeLibrary As TypeLibInfo
    Dim Class As CoClassInfo
    ' raises an error if unable to open the type library
    ' (e.g. file not found or not a TLB)
    Set TypeLibrary = TLI.TypeLibInfoFromFile(TypeLibFile)
    ' prepare the result
    Set GetClasses = New Collection

    ' fill the return collection with class names
    For Each Class In TypeLibrary.CoClasses
        ' exclude not creatable classes if necessary
        If IncludeNotCreatableClasses Or (Class.AttributeMask And _
            ' the class is creatable or we don't care
            ' about the creatable attribute
            GetClasses.Add Class.Name, Class.Name
        End If
End Function
Alberto Falossi
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date