Как искать файлы в скрытых файлах? Просьба всякие контролы не предлагать. Меня интересует только чистое API... Как просто искать я знаю. А в скрытых папках мой код не работает. Испотзую функции - FindFirstFile и FindNextFile. Ну и FindClose. Вот мой код:
Public Const MAX_PATH = 260
Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Public Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Public Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Public Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Public FUCK() As String ' Массив в который записываются найденные файлы
Public FUCKCount As Integer
Function StripNulls(OriginalStr As String) As String
If (InStr(OriginalStr, Chr(0)) > 0) Then
OriginalStr = Left(OriginalStr, _
InStr(OriginalStr, Chr(0)) - 1)
End If
StripNulls = OriginalStr
End Function
Sub FindFile(Path As String, File As String)
Dim WFD As WIN32_FIND_DATA
Dim FhWnd As Long
Dim PFName As String
Dim PathNames() As String
Dim Cont As Long
Dim ContPath As Integer
FhWnd = FindFirstFile(Path & "*", WFD)
If Not FhWnd = -1 Then
Cont = True
While Cont
If WFD.dwFileAttributes = 16 Then
PFName = StripNulls(WFD.cFileName)
If Not PFName = "." And Not PFName = ".." Then
ContPath = ContPath + 1
ReDim Preserve PathNames(ContPath)
PathNames(ContPath) = Path & PFName & "\"
End If
End If
Cont = FindNextFile(FhWnd, WFD)
Wend
End If
Cont = FindClose(FhWnd)
FhWnd = FindFirstFile(Path & File, WFD)
If Not FhWnd = -1 Then
Cont = True
While Cont
If WFD.dwFileAttributes <> 16 Then
PFName = StripNulls(WFD.cFileName)
If Not PFName = "." And Not PFName = ".." Then
FUCKCount = FUCKCount + 1
ReDim Preserve FUCK(FUCKCount)
FUCK(FUCKCount) = Path & PFName
End If
End If
Cont = FindNextFile(FhWnd, WFD)
Wend
End If
Cont = FindClose(FhWnd)
For i = 1 To ContPath
Call FindFile(PathNames(i), File)
Next i
End Sub