获取对象的接口信息(方法/属性/事件)(VB6代码)
作者:admin 日期:2009-06-29
要不是WS的超级绿豆提起这东西,我还不知道呢....
真是个好玩意!!能列出一个对象的接口,包括方法,属性,事件.....微软直接做了啊.
记录一下,以后要用到时免得忘了:
Option Explicit
'引用Library TLI
' C:\WINDOWS\system32\TLBINF32.DLL
' TypeLib Information
Private Sub Form_Load()
Dim oTLB As InterfaceInfo,I As Long
Set oTLB = TLI.InterfaceInfoFromObject(Me)
Debug.Print oTLB.Name
For I = 1 To oTLB.Members.Count
Select Case oTLB.Members(I).InvokeKind
Case INVOKE_CONST
Debug.Print " 常数:" & oTLB.Members(I).Name
Case INVOKE_EVENTFUNC
Debug.Print " 事件:" & oTLB.Members(I).Name
Case INVOKE_FUNC
Debug.Print " 方法:" & oTLB.Members(I).Name
Case INVOKE_PROPERTYGET
Debug.Print "属性(Get):" & oTLB.Members(I).Name
Case INVOKE_PROPERTYPUT
Debug.Print "属性(Let):" & oTLB.Members(I).Name
Case INVOKE_PROPERTYPUTREF
Debug.Print "属性(Set):" & oTLB.Members(I).Name
Case INVOKE_UNKNOWN
Debug.Print " 未知:" & oTLB.Members(I).Name
End Select
Next
End Sub'
原文链接:https://www.f2er.com/vb/256992.html真是个好玩意!!能列出一个对象的接口,包括方法,属性,事件.....微软直接做了啊.
记录一下,以后要用到时免得忘了:
Option Explicit
'引用Library TLI
' C:\WINDOWS\system32\TLBINF32.DLL
' TypeLib Information
Private Sub Form_Load()
Dim oTLB As InterfaceInfo,I As Long
Set oTLB = TLI.InterfaceInfoFromObject(Me)
Debug.Print oTLB.Name
For I = 1 To oTLB.Members.Count
Select Case oTLB.Members(I).InvokeKind
Case INVOKE_CONST
Debug.Print " 常数:" & oTLB.Members(I).Name
Case INVOKE_EVENTFUNC
Debug.Print " 事件:" & oTLB.Members(I).Name
Case INVOKE_FUNC
Debug.Print " 方法:" & oTLB.Members(I).Name
Case INVOKE_PROPERTYGET
Debug.Print "属性(Get):" & oTLB.Members(I).Name
Case INVOKE_PROPERTYPUT
Debug.Print "属性(Let):" & oTLB.Members(I).Name
Case INVOKE_PROPERTYPUTREF
Debug.Print "属性(Set):" & oTLB.Members(I).Name
Case INVOKE_UNKNOWN
Debug.Print " 未知:" & oTLB.Members(I).Name
End Select
Next
End Sub'