Find Files using FindFirstFile,FindNextFile and FindClose API
Find Files using FindFirstFile,FindNextFile and FindClose API
API Declarations
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private 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 * 260
cAlternate As String * 14
End Type
Private Declare Function FindNextFile Lib "kernel32.dll" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindFirstFile Lib "kernel32.dll" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32.dll" (ByVal hFindFile As Long) As Long
Rate Find Files using FindFirstFile,FindNextFile and FindClose API
(1(1 Vote))
Dim handle As Long
Dim finfo As WIN32_FIND_DATA
Dim found As Long
Dim buffer As String
Dim rval As Long
Dim c As Integer
List1.Clear
handle = FindFirstFile(Text1.Text, finfo)'Find files in path entered in the textbox
If handle = -1 Then
MsgBox "No files found"
End
End If
c = 0
Do
buffer = Space(128)
buffer = Left(finfo.cFileName, InStr(finfo.cFileName, Chr(0)) - 1) 'Extract the found filename
buffer = buffer & "---------> " & finfo.nFileSizeLow & " Bytes"
'MsgBox buffer
List1.AddItem buffer, c
c = c + 1
found = FindNextFile(handle, finfo)
Loop Until found = 0
rval = FindClose(handle)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{TAB}"
SendKeys "{ENTER}"
End If
End Sub
Find Files using FindFirstFile,FindNextFile and FindClose API Comments
No comments yet — be the first to post one!
Post a Comment