Function FindFilesAPI(path As String, SearchStr As String, FileCount As Integer, DirCount As Integer)
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
Screen.MousePointer = vbHourglass
Dim fileName As String ' Walking filename variable...
Dim DirName As String ' SubDirectory Name
Dim dirNames() As String ' Buffer for directory name entries
Dim nDir As Integer ' Number of directories in this path
Dim i As Integer ' For-loop counter...
Dim hSearch As Long ' Search Handle
Dim WFD As WIN32_FIND_DATA
Dim Cont As Integer
If Right(path, 1) <> "\" Then path = path & "\"
' Search for subdirectories.
nDir = 0
ReDim dirNames(nDir)
Cont = True
hSearch = FindFirstFile(path & "*", WFD)
If hSearch <> INVALID_HANDLE_VALUE Then
Do While Cont
DoEvents
DirName = StripNulls(WFD.cFileName)
' Ignore the current and encompassing directories.
If (DirName <> ".") And (DirName <> "..") Then
' Check for directory with bitwise comparison.
If GetFileAttributes(path & DirName) And FILE_ATTRIBUTE_DIRECTORY Then
dirNames(nDir) = DirName
DirCount = DirCount + 1
nDir = nDir + 1
ReDim Preserve dirNames(nDir)
End If
End If
Cont = FindNextFile(hSearch, WFD) 'Get next subdirectory.
Loop
Cont = FindClose(hSearch)
End If
' Walk through this directory and sum file sizes.
hSearch = FindFirstFile(path & SearchStr, WFD)
Cont = True
If hSearch <> INVALID_HANDLE_VALUE Then
While Cont
DoEvents
fileName = StripNulls(WFD.cFileName)
If (fileName <> ".") And (fileName <> "..") Then
FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * MAXDWORD) + WFD.nFileSizeLow
FileCount = FileCount + 1
List1.AddItem path & fileName
Dim ixi As Long
For ixi = 0 To List1.ListCount - 1
If InStr(1, UCase(List1.List(ixi)), "Windows", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "WINNT\SchedLgU.txt", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "Windows\SchedLgU.txt", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "0ab10246f7cddc39151aba", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "WINNT\vmmreg32.dll", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "Windows\vmmreg32.dll", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "MHX Antivirus and Antispyware Free Edition", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "Games\Neosteam\Update.exe", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
If InStr(1, UCase(List1.List(ixi)), "\MSN\MSNCoreFiles\Update.exe", vbTextCompare) > 0 Then
List1.RemoveItem ixi
End If
Next
End If
Cont = FindNextFile(hSearch, WFD) ' Get next file
Wend
Cont = FindClose(hSearch)
End If
' If there are sub-directories...
If nDir > 0 Then
' Recursively walk into them...
For i = 0 To nDir - 1
FindFilesAPI = FindFilesAPI + FindFilesAPI(path & dirNames(i) & "\", SearchStr, FileCount, DirCount)
Next i
End If
Screen.MousePointer = vbDefault
End Function