VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsCOMReporter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' clsCOMReporter: Reports TypeLib information for COM Comnponents
Option Explicit


Public Event status(ByVal msg As String)

Public Function header() As String
    header = "COMPATH" & vbTab & "COMNAME" & vbTab & "EXT" & vbTab & "LIBGUID" & vbTab & "LIBNAME"
End Function

Public Sub processFile(fil As Scripting.File, rpt As Scripting.TextStream)
    Const FUNC_NAME$ = "processFile"
   
    Dim filpath As String: filpath = fil.ParentFolder.Path
    Dim filname As String: filname = fil.name
    
    Dim libname As String
    Dim libguid As String
    
    On Error Resume Next
    Dim tliApp As TLI.TLIApplication
    Set tliApp = New TLI.TLIApplication
    Dim tlinfo  As TLI.TypeLibInfo
    Set tlinfo = tliApp.TypeLibInfoFromFile(fil.Path)
    If Err = TLI.tliErrCantLoadLibrary Then
        libname = "-"
        libguid = "ERR=" & Err.Number & ": " & Err.Description
        Err.Clear
    Else
        libname = tlinfo.name
        libguid = tlinfo.Guid
    End If
    On Error GoTo errorHandler
    
    Dim filextn As String
    Dim i As Integer
    i = InStrRev(filname, ".")
    If i > 0 Then
       filextn = Mid$(fil.name, i + 1)
    Else
       filextn = "-"
    End If
    
    Call writeRpt(rpt, _
    filpath & vbTab & _
    filname & vbTab & _
    filextn & vbTab & _
    libguid & vbTab & _
    libname & vbCrLf)
    
errorHandler:
    
    Set tlinfo = Nothing
    
    If Err Then _
        Err.Raise Err.Number, Description:=TypeName(Me) & "::" & FUNC_NAME$ & " " & _
        vbCrLf & "[" & fil.Path & "]" & _
        vbCrLf & Err.Description
        
End Sub
