Hi there! I've got a problem. The following lines
will show you a sample part of a MSDN libary code:
---- There are 3 elements in the WIN32_FIND_DATA type:Code:Public Const MAX_PATH = 260 Public Const MAXDWORD = &HFFFF Public Const INVALID_HANDLE_VALUE = -1 Public Const FILE_ATTRIBUTE_ARCHIVE = &H20 Public Const FILE_ATTRIBUTE_DIRECTORY = &H10 Public Const FILE_ATTRIBUTE_HIDDEN = &H2 Public Const FILE_ATTRIBUTE_NORMAL = &H80 Public Const FILE_ATTRIBUTE_READONLY = &H1 Public Const FILE_ATTRIBUTE_SYSTEM = &H4 Public Const FILE_ATTRIBUTE_TEMPORARY = &H100 Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type 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 Function FindFilesAPI(strPath As String, SearchStr As String, _ FileCount As Integer, DirCount As Integer) On Error Resume Next Dim FileName As String Dim DirName As String Dim DirNames() As String Dim nDir As Integer Dim hSearch As Long Dim i As Integer Dim WFD As WIN32_FIND_DATA Dim Cont As Integer Dim ErrorCount As Integer If Right(strPath, 1) <> "\" Then strPath = strPath & "\" nDir = 0 ReDim DirNames(nDir) Cont = True hSearch = FindFirstFile(strPath & "*", WFD) If hSearch <> INVALID_HANDLE_VALUE Then Do While Cont DirName = StripNulls(WFD.cFileName) If (DirName <> ".") And (DirName <> "..") Then If GetFileAttributes(strPath & 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) Loop Cont = FindClose(hSearch) End If hSearch = FindFirstFile(strPath & SearchStr, WFD) Cont = True If hSearch <> INVALID_HANDLE_VALUE Then While Cont FileName = StripNulls(WFD.cFileName) If (FileName <> ".") And (FileName <> "..") And _ ((GetFileAttributes(strPath & FileName) And Not _ FILE_ATTRIBUTE_DIRECTORY)) Then FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * _ MAXDWORD) + WFD.nFileSizeLow FileCount = FileCount + 1 Call NameMp3(FileName, strPath) 'This is a own defined function End If Cont = FindNextFile(hSearch, WFD) Wend Cont = FindClose(hSearch) End If If nDir > 0 Then For i = 0 To nDir - 1 FindFilesAPI = FindFilesAPI + FindFilesAPI(strPath & DirNames(i) _ & "\", SearchStr, FileCount, DirCount) Next i End If End Function
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
I don't want to have that elements in that type.
If I remove this part of code, the FILETIME type
is also not needed any more.
But when I do this, the function will return something
about 207 file(s) found in 58 directories or something
like that.
I also removed this part:
FindFilesAPI = FindFilesAPI + (WFD.nFileSizeHigh * _
MAXDWORD) + WFD.nFileSizeLow
----
This sample function allows you t o search for
files in a directory and in its subdirectories.
The original code also counted the bytes of the files
and the time when they were created.
I don't need that to be in this code.
Any suggestions how to make a nice function for that?
thx, vbzero




Reply With Quote