'This Code need 2 TextBox and 2 Command button with this properties set
'1st textbox.name=PathFile
'2st textbox.name=Listview
'2st textbox.ScrollBars=2-vertical
'2st textbox.Multiline=true
'1st command button.name=Browse
'2st command button.name=Found
Option Explicit
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Dim OFName As OPENFILENAME, ListDumm(1000) As String, Jc As Integer, ListADDCont As Integer
Private Function ShowOpen() As String
OFName.lStructSize = Len(OFName)
OFName.hwndOwner = Me.hWnd
OFName.hInstance = App.hInstance
OFName.lpstrFilter = _
"Windows Portable Executables" + Chr(0) + "*.exe;*.ocx;*.dll" + Chr(0) + _
"All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
OFName.lpstrFile = Space$(254)
OFName.nMaxFile = 255
OFName.lpstrFileTitle = Space$(254)
OFName.nMaxFileTitle = 255
OFName.lpstrInitialDir = "C:\"
OFName.lpstrTitle = "Open PE File "
OFName.flags = 0
If GetOpenFileName(OFName) Then
ShowOpen = Trim$(OFName.lpstrFile)
Else
ShowOpen = ""
End If
End Function
Private Sub Browse_Click()
On Error GoTo Error_Section:
Dim dumm As String
dumm = ShowOpen
If dumm <> "" And Dir(dumm) <> "" Then
PathFile = dumm
Found.Enabled = True
Else
Found.Enabled = False
End If
Exit Sub
Error_Section:
MsgBox Err.Source & " reports " & Err.Description, , "Error " & Err.Number
End Sub
Private Sub Form_Load()
With Me
.Visible = False
.ScaleMode = 1
.Width = 4800
.Height = 3405
End With
With Found
.Caption = "&Found"
.Width = 735
.Top = 600
.Height = 375
.Left = 3840
.Enabled = False
End With
With PathFile
.Top = 120
.Height = 375
.Width = 3735
.Left = 120
End With
With Browse
.Caption = "..."
.Height = 375
.Left = 4080
.Top = 120
.Width = 375
End With
With ListView
.Width = 3615
.Top = 600
.Left = 120
.Height = 2295
.Locked = True
End With
Me.Visible = True
Jc = 0
End Sub
Private Sub Found_Click()
Dim tempStr As String
If PathFile = "" Or Dir(PathFile) = "" Then Exit Sub
tempStr = Me.Caption
Me.Caption = tempStr + " : [Searching] Please wait . . ."
ListView = ""
Jc = 0
GetImortFiles
DoEvents
RemoveUnNesseceryAdd
UpdateList
Me.Caption = tempStr + " : Done"
End Sub
Private Sub PathFile_Change()
If PathFile <> "" And Dir(PathFile) <> "" Then
Found.Enabled = True
Else
Found.Enabled = False
End If
End Sub
Private Sub GetImortFiles()
Dim Contents As String
On Local Error Resume Next
Jc = 0
If Dir(PathFile) = "" Then
Found.Enabled = False
Exit Sub
End If
Open PathFile For Binary As #1
Contents = Space$(LOF(1))
Get #1, , Contents
Close #1
Contents = UCase$(Contents)
ReadImportList Contents, ".DLL"
DoEvents
ReadImportList Contents, ".OCX"
End Sub
Private Sub ReadImportList(ByVal strContents As String, ByVal strFind As String)
Dim lngExtLocation As Long, lngBlankLocation As Long, tempStr As String
lngExtLocation = InStr(1, strContents, strFind)
lngBlankLocation = lngExtLocation
Do
Do
lngBlankLocation = lngBlankLocation - 1
tempStr = Mid$(strContents, lngBlankLocation, 1)
If Asc(tempStr) = 0 Or Trim$(tempStr) = "\" Then Exit Do
Loop
tempStr = Mid$(strContents, lngBlankLocation + 1, _
lngExtLocation - lngBlankLocation + Len(strFind) - 1)
ListDumm(Jc) = Trim$(tempStr)
Jc = Jc + 1
lngExtLocation = InStr(lngExtLocation + 4, strContents, strFind)
lngBlankLocation = lngExtLocation
DoEvents
Loop While lngExtLocation > 0
End Sub
Private Sub RemoveUnNesseceryAdd()
Dim str As String, i As Long, d As Long
On Local Error Resume Next
i = 0: d = 0
Do While i < Jc
str = UCase$(ListDumm(i))
If LenB(str) Then
d = 1 + i
Do While d < Jc
If str = UCase(ListDumm(d)) Then
ListDumm(d) = ""
End If
d = d + 1
Loop
End If
i = i + 1
If Int(i / 40) = 0 Then DoEvents
Loop
End Sub
Private Sub UpdateList()
Dim i As Long
ListADDCont = 0
For i = 0 To Jc
If ListDumm(i) <> vbNullString And Left$(Trim$(Right$(ListDumm(i), 4)), 1) = "." Then
ListView = ListView + ListDumm(i) + Chr(13) + Chr(10)
ListADDCont = ListADDCont + 1
End If
Next i
End Sub