Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enumerating functions from an ActiveX control 3

Status
Not open for further replies.

instar4per

Programmer
Jan 21, 2002
48
US
I know it's possible, obviously, as VB is able to do it when we add a control to a form, and view it's properties. I've looked around (not hours, but not just one time), and haven't found anything very useful.

If anyone has any insight as to how to do at least pull the function names (maybe not the parameters, if need-be) from an ActiveX DLL and/or OCX module, I would appreciate it.

Thanks,
-iNSTA
 
There are several ways of doing this. Most use the TypeLib Information library (you can add this through References). Here's one example (you just need a form with a command button):
[tt]
Option Explicit

Private Sub Command1_Click()
PropertyWalk Form1 'myobj
End Sub

' Function that walks through the properties of an object
' In this example we happen to only be interested in Function properties
Public Sub PropertyWalk(ByRef QueriedObject As Object)

Dim TLIApp As TLIApplication
Dim TLInfo As TLI.InterfaceInfo

Dim MI As MemberInfo
Dim ParamCount As Long


Set TLIApp = New TLIApplication
' grab info from object
Set TLInfo = TLI.InterfaceInfoFromObject(QueriedObject)

' Loop through attribute members of the object
For Each MI In TLInfo.Members

Select Case MI.InvokeKind
Case INVOKE_CONST 'Constant
Case INVOKE_EVENTFUNC ' Event
Case INVOKE_FUNC ' sub/function
' AT this point MI contains all the info you need about a class
Debug.Print MI.Name & "(";
For ParamCount = 1 To MI.Parameters.Count
If ParamCount <> 1 Then Debug.Print &quot;,&quot;;
If MI.Parameters(ParamCount).Optional Then Debug.Print &quot;Optional &quot;;
Debug.Print MI.Parameters(ParamCount);
Next
Debug.Print &quot;)&quot;
Case INVOKE_PROPERTYGET ' Get
Case INVOKE_PROPERTYPUT ' Let

Case INVOKE_PROPERTYPUTREF ' Set
Case INVOKE_UNKNOWN ' Dunno
Case Else 'Oops
End Select
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top