VBS查看對象信息

 
Const ForReading = 1 '以只讀模式打開文件。不能對此文件進行寫操作。
Const ForWriting = 2 '以可讀寫模式打開文件。如果已存在同名的文件,則覆蓋舊的文件。
Const ForAppending = 8 '打開文件並在文件末尾進行寫操作。

Dim fso 
Set fso = CreateObject("scripting.filesystemobject")
Set infoOutputFile = fso.getfile("tlbinfo.ini") '設置一個文件對象..filepath就是這個模板文件的名稱
Set infoLog = infoOutputFile.openastextstream(ForWriting) '設置一個文本對象..並打開這個對象... 

Set tli = CreateObject("TLI.TLIApplication") 

Set Info = tli.TypeLibInfoFromFile("tlbinf32.dll")

infoLog.write "#-----------------tlbinf32.dll-----------------" & vbCrLf
infoLog.write "[BaseInfo]" & vbCrLf
infoLog.write "Name=" & Info.Name & vbCrLf
infoLog.write "AppObjString=" & Info.AppObjString & vbCrLf
infoLog.write "ContainingFile=" & Info.ContainingFile & vbCrLf
infoLog.write "HelpString=" & Info.HelpString & vbCrLf
infoLog.write "HelpStringDLL=" & Info.HelpStringDLL & vbCrLf
infoLog.write "HelpFile=" & Info.HelpFile & vbCrLf
infoLog.write "GUID=" & Info.GUID & vbCrLf
infoLog.write "MajorVersion=" & Info.MajorVersion & vbCrLf
infoLog.write "MinorVersion=" & Info.MinorVersion & vbCrLf
infoLog.write "AttributeMask=" & Info.AttributeMask & vbCrLf
'IF Not (Info.AttributeStrings Is Nothing) Then
'	infoLog.write "AttributeStrings=" & Info.AttributeStrings & vbCrLf
'End IF
'infoLog.write "AttributeStrings=" & Info.AttributeStrings & vbCrLf
infoLog.write "LibNum=" & Info.LibNum & vbCrLf
infoLog.write "ShowLibName=" & Info.ShowLibName & vbCrLf

infoLog.write vbCrLf

IName = ""
For Each Interface In Info.Interfaces 
	IName = IName & Interface.Name & vbCrLf
Next
infoLog.write "[Interfaces]" & vbCrLf & IName & vbCrLf

TName = ""
For Each TypeInfo In Info.TypeInfos
	PName = PName & TypeInfo.Name & vbCrLf
Next
infoLog.write "[TypeInfos]" & vbCrLf & PName & vbCrLf

CocName = ""
For Each CoClass In Info.CoClasses
	CocName = CocName & CoClass.Name & vbCrLf
Next
infoLog.write "[CoClasses]" & vbCrLf & CocName & vbCrLf

ConstantName = ""
For Each Constant In Info.Constants
	ConstantName = ConstantName & Constant.Name & vbCrLf
Next
infoLog.write "[Constants]" & vbCrLf & ConstantName & vbCrLf

DeclarationName = ""
For Each Declaration In Info.Declarations
	DeclarationName = DeclarationName & Declaration.Name & vbCrLf
Next
infoLog.write "[Declarations]" & vbCrLf & DeclarationName & vbCrLf

RecordName = ""
For Each Record In Info.Records
	RecordName = RecordName & Record.Name & vbCrLf
Next
infoLog.write "[Records]" & vbCrLf & RecordName & vbCrLf

IntrinsicAliasName = ""
For Each IntrinsicAlias In Info.IntrinsicAliases
	IntrinsicAliasName = IntrinsicAliasName & IntrinsicAlias.Name & vbCrLf
Next
infoLog.write "[IntrinsicAliases]" & vbCrLf & IntrinsicAliasName & vbCrLf

CustomDataName = ""
For Each CustomData In Info.CustomDataCollection
	CustomDataName = CustomDataName & CustomData.Name & vbCrLf
Next
infoLog.write "[CustomDataCollection]" & vbCrLf & CustomDataName & vbCrLf

UnionName = ""
For Each Union In Info.Unions
	UnionName = UnionName & Union.Name & vbCrLf
Next
infoLog.write "[Unions]" & vbCrLf & UnionName & vbCrLf

MName = ""
For Each CoClass In Info.CoClasses
	infoLog.write "[" & CoClass.Name & "]" & vbCrLf
	For Each Member In CoClass.DefaultInterface.Members
		MName = MName & Member.Name & vbCrLf
	Next
	infoLog.write MName & vbCrLf & vbCrLf
Next

infoLog.Close


發佈了56 篇原創文章 · 獲贊 11 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章