如何得到一个对象中所有过程、属性、方法名的的字符串?
如:
如题,有什么方法?xiexie
问题点数:30、回复次数:3Top
1 楼rainstormmaster(暴风雨 v2.0)回复于 2004-02-01 13:33:29 得分 30
用TypeLib Information(工程 引用 选择并加载peLib Information)
用法参考:
http://www.vb-helper.com/howto_get_property_information.html
详细情况请查询MSDNTop
2 楼SonicOne(用心猫)回复于 2004-02-01 21:27:26 得分 0
Title Get information about all of a control's properties
Keywords control property, property information, TypeLib
Categories Controls, Software Engineering
Thanks to Oigres P.
Set a project reference to the TypeLib Information library. Create a TLIApplication object and get an InterfaceInfo object for the control from its InterfaceInfoFromObject function. Then iterate through the interface's members.
Private Sub Command1_Click()
''caution crashes if you try to read the Form1
' properties
iterateMembers Text1
End Sub
Sub iterateMembers(obj As Object)
'iterate the members in the textbox interface
'put them in a flexgrid for viewing
Dim TLI As New TLIApplication, ret As Variant
Dim interface As InterfaceInfo
Dim member As MemberInfo
On Error Resume Next
Set interface = TLI.InterfaceInfoFromObject(obj)
Dim index As Long, tempstr As String
ReDim str(interface.Members.Count) As String
index = 0
For Each member In interface.Members
tempstr = ""
tempstr = tempstr & member.Name & vbTab & _
member.VTableOffset & vbTab & _
Hex$(member.MemberId) & _
vbTab & member.HelpString
'get property value; using memberID is faster than
' member.Name
ret = TLI.InvokeHook(Text1, member.MemberId, _
INVOKE_PROPERTYGET)
'adjust long values; convert to hex (else shows neg
' value)
If TypeName(ret) = "Long" Then
ret = "&H" & Hex(ret) & "&"
tempstr = tempstr & vbTab & ret & vbTab & "long"
Else
tempstr = tempstr & vbTab & ret & vbTab & _
TypeName(ret)
End If
'store row data in array
str(index) = tempstr
index = index + 1
Next
Set TLI = Nothing
fillGrid str()
End Sub
Top
3 楼SonicOne(用心猫)回复于 2004-02-01 21:27:53 得分 0
万分感谢,我追加10分Top
相关问题
- 能否用字符串访问类的属性 方法
- 把字符串转换为一个对象用什么方法??
- 如何使用字符串实现对对象属性的修改???????????????????????
- 如何能将字符串类型的控件名转换成控件对象,调用属性?
- 如何能将字符串类型的控件名转换成控件对象,调用属性?
- 请问在RDS对象中怎么写出oracle的连接字符串connect与server属性
- 字符串类型的属性问题
- 如何递归遍历某一对象的所有属性(包括可展开属性的子属性),并以字符串形式返回?
- 用什么方法,可以把一个String型的字符串赋给JTextField对象?谢谢!
- 如何把利用DataSet的GetXml()方法获得的字符串再转成DataSet对象??




