1.Start Visual Basic and chose Standard Exe or, if Visual Basic is already running, choose New Project from the File menu.
2.Set a reference to the file Tlbinf32.dll by completing the following steps:
From the Project menu, click References. The References dialog box is displayed.
From the References dialog box, click Browse.
From your Windows system directory, select the file Tlbinf32.dll. 3.Add the following controls to the Form1 form and set the indicated properties:
Control Property Name Property Setting
----------------------------------------------------------------
Command Button Name Command1
Caption Choose File
Height 495
Left 4800
TabIndex 3
Top 720
Width 1815 Command Button Name Command2
Caption End
Height 495
Left 4800
TabIndex 4
Top 1320
Width 1815 Text Box Name Text1
Height 375
Left 1080
TabIndex 1
Top 120
Width 5535 List Box Name List1
Height 2205
Left 120
Top 720
Width 4455 Common Dialog Name CommonDialog1 Label Name Label1
Caption Selected DLL
Height 375
Left 0
TabIndex 2
Top 120
Width 1095
Copy and paste the following code to the Code window of the Form1 form.
Private Sub Form_Load()
strFilter = "DLL Files (*.dll)|*.dll|"
strFilter = strFilter & "OCX Files (*.ocx)|*.ocx|"
strFilter = strFilter & "All Files (*.*)|*.*"
CommonDialog1.Filter = strFilter
End Sub Private Sub Command1_Click()
Dim x As TypeLibInfo
Dim y As CoClasses
Dim z As Interfaces
Dim w As Members
Dim u As MemberInfo
Dim i As Integer, j As Integer, n As Integer, k As Integer
Dim strFilter As String
Dim strName As String, strMembers As String On Error Resume Next
CommonDialog1.ShowOpen
List1.Clear
Text1.Text = "" 'Program ends if you click the Cancel button in the
'file open dialog box
If CommonDialog1.Flags = 0 Then
End
End If 'Get information from type library
Set x = TypeLibInfoFromFile(CommonDialog1.filename)
Set y = x.CoClasses 'Show Type Library information in the List box
For i = 1 To y.Count
If i <> 1 Then
strName = ""
List1.AddItem strName
End If
strName = "Class Name: " & y.Item(i).Name
List1.AddItem strName
Set z = y.Item(i).Interfaces
For n = 1 To z.Count
Set w = z.Item(n).Members
For k = 1 To w.Count
Set u = w.Item(k)
strMembers = " Member: " & u.Name
List1.AddItem strMembers
Next
Next
Next
Set z = Nothing
Set y = Nothing
Set x = Nothing
Set w = Nothing 'Display filename in the text box
Text1.Text = CommonDialog1.filename 'If the file does not contain type library information
'then display this error message.
If Err.Number = 91 Then
Dim strMsgTitle As String, strMsgError As String
Dim intResponse
strMsgTitle = "No Type Library"
strMsgError = "You chose a file without a type library. "
strMsgError = strMsgError & "Choose another file."
Err.Clear
intResponse = MsgBox(strMsgError, vbOKCancel, strMsgTitle) If intResponse = vbOK Then
Command1_Click
End If End If End Sub Private Sub Command2_Click()
End
End Sub
4.Press the F5 key to run the program. Select a .dll or an ActiveX control file. If the file contains a type library, the class names and members are displayed in the list box. 文:
SAMPLE: CLSNMMBR.EXE Programmatically Retrieves the Members of a DLL Class
http://support.microsoft.com/support/kb/articles/Q172/9/88.ASP
例:
http://download.microsoft.com/download/vb50pro/sample/3/WIN98/EN-US/Clsnmmbr.exe
2.Set a reference to the file Tlbinf32.dll by completing the following steps:
From the Project menu, click References. The References dialog box is displayed.
From the References dialog box, click Browse.
From your Windows system directory, select the file Tlbinf32.dll. 3.Add the following controls to the Form1 form and set the indicated properties:
Control Property Name Property Setting
----------------------------------------------------------------
Command Button Name Command1
Caption Choose File
Height 495
Left 4800
TabIndex 3
Top 720
Width 1815 Command Button Name Command2
Caption End
Height 495
Left 4800
TabIndex 4
Top 1320
Width 1815 Text Box Name Text1
Height 375
Left 1080
TabIndex 1
Top 120
Width 5535 List Box Name List1
Height 2205
Left 120
Top 720
Width 4455 Common Dialog Name CommonDialog1 Label Name Label1
Caption Selected DLL
Height 375
Left 0
TabIndex 2
Top 120
Width 1095
Copy and paste the following code to the Code window of the Form1 form.
Private Sub Form_Load()
strFilter = "DLL Files (*.dll)|*.dll|"
strFilter = strFilter & "OCX Files (*.ocx)|*.ocx|"
strFilter = strFilter & "All Files (*.*)|*.*"
CommonDialog1.Filter = strFilter
End Sub Private Sub Command1_Click()
Dim x As TypeLibInfo
Dim y As CoClasses
Dim z As Interfaces
Dim w As Members
Dim u As MemberInfo
Dim i As Integer, j As Integer, n As Integer, k As Integer
Dim strFilter As String
Dim strName As String, strMembers As String On Error Resume Next
CommonDialog1.ShowOpen
List1.Clear
Text1.Text = "" 'Program ends if you click the Cancel button in the
'file open dialog box
If CommonDialog1.Flags = 0 Then
End
End If 'Get information from type library
Set x = TypeLibInfoFromFile(CommonDialog1.filename)
Set y = x.CoClasses 'Show Type Library information in the List box
For i = 1 To y.Count
If i <> 1 Then
strName = ""
List1.AddItem strName
End If
strName = "Class Name: " & y.Item(i).Name
List1.AddItem strName
Set z = y.Item(i).Interfaces
For n = 1 To z.Count
Set w = z.Item(n).Members
For k = 1 To w.Count
Set u = w.Item(k)
strMembers = " Member: " & u.Name
List1.AddItem strMembers
Next
Next
Next
Set z = Nothing
Set y = Nothing
Set x = Nothing
Set w = Nothing 'Display filename in the text box
Text1.Text = CommonDialog1.filename 'If the file does not contain type library information
'then display this error message.
If Err.Number = 91 Then
Dim strMsgTitle As String, strMsgError As String
Dim intResponse
strMsgTitle = "No Type Library"
strMsgError = "You chose a file without a type library. "
strMsgError = strMsgError & "Choose another file."
Err.Clear
intResponse = MsgBox(strMsgError, vbOKCancel, strMsgTitle) If intResponse = vbOK Then
Command1_Click
End If End If End Sub Private Sub Command2_Click()
End
End Sub
4.Press the F5 key to run the program. Select a .dll or an ActiveX control file. If the file contains a type library, the class names and members are displayed in the list box. 文:
SAMPLE: CLSNMMBR.EXE Programmatically Retrieves the Members of a DLL Class
http://support.microsoft.com/support/kb/articles/Q172/9/88.ASP
例:
http://download.microsoft.com/download/vb50pro/sample/3/WIN98/EN-US/Clsnmmbr.exe
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货