I want to write a utility that will search for all registered activex objects, and then check the typelib for a particular property. I am using this so I can provide users a list of valid "add-ins" to our applications. All add-ins to our application must implement an interface, which contains a property indicating it is an add-in for our application.
I have the code, via
www.vb2themax.com to search the typelib. I want to get a list of all activex OCX/DLL/EXEs. How can I do that?
Date: 8/26/2000
Versions: VB5 VB6
Author: The VB2TheMax Team
' return a collection with names of all the class names
' of a type library that implement a certain member.
'
' MEMBERNAME is the name of the property or method
' MEMBERTYPE is the type of the member (vbGet, vbLet, vbSet, vbMethod).
' You can specify multiple types by ORing these constants
'
' Example:
' Dim tlb As String
' Dim retColl As Collection
' tlb = "C:\MyServer.Dll"
' ' returns all types with MyProp (Let, Set or Get) property
' Set retColl = GetClassesByMember(tlb, "MyProp", VbLet Or VbSet Or VbGet)
' ' returns all types with MyProp Let property
' Set retColl = GetClassesByMember(tlb, "MyProp", VbLet)
' ' returns all types with MyFunc function (or Sub)
' Set retColl = GetClassesByMember(tlb, "MyFunc", VbMethod)
' Be sure that "TypeLib Information" type library (TlbInf32.tlb)
' is referenced in your VB project.
Function GetClassesByMember(ByVal TypeLibFile As String, _
ByVal MemberName As String, MemberType As VbCallType) As Collection
Dim TLI As New TLIApplication
Dim TypeLibrary As TypeLibInfo
Dim TypeInfo As TypeInfo
Dim Results As SearchResults
Dim Item As SearchItem
' raises an error if unable to open the type library
' (e.g. file not found or not a TLB)
Set TypeLibrary = TLI.TypeLibInfoFromFile(Ty
peLibFile)
' prepare the result
Set GetClassesByMember = New Collection
' search types containing the requested member
Set Results = TypeLibrary.GetTypesWithMe
mberEx(Mem
berName, MemberType, , _
tliStClasses)
' fill the return collection with found type names
For Each Item In Results
GetClassesByMember.Add Item.Name, Item.Name
Next
End Function