|
' ******************************************************
' ˆê——‚̎擾
' ******************************************************
Public Function lbFTPEnum( _
strDirectory As String, _
strTarget As String, _
Grid As Object _
) As Long
Dim bFirst As Boolean
Dim lpData As WIN32_FIND_DATA
Dim hFind As Long
Dim nRet As Long
Dim nLastDllError As Long
bFirst = True
Grid.Clear
Grid.Cols = 7
Grid.Rows = 2
With Grid
.TextMatrix(0, 1) = "FileName"
.TextMatrix(0, 2) = "CreationTime"
.TextMatrix(0, 3) = "LastAccessTime"
.TextMatrix(0, 4) = "LastWriteTime"
.TextMatrix(0, 5) = "FileAttributes"
.TextMatrix(0, 6) = "FileSizeLow"
End With
Do
If bFirst Then
bFirst = False
hFind = FtpFindFirstFile(hCon, strDirectory & "/" & strTarget, lpData, 0, 0)
nLastDllError = Err.LastDllError
If hFind = 0 Then
If (nLastDllError = 18) Then
lbFTPEnum = 0
Else
lbFTPEnum = -1
End If
Exit Function
End If
Else
nRet = InternetFindNextFile(hFind, lpData)
nLastDllError = Err.LastDllError
If nRet = 0 Then
If (nLastDllError = 18) Then
Exit Do
Else
lbFTPEnum = -1
Call InternetCloseHandle(hFind)
Exit Function
End If
End If
Grid.Rows = Grid.Rows + 1
End If
With Grid
.TextMatrix(.Rows - 1, 0) = .Rows - 1
.TextMatrix(.Rows - 1, 1) = lpData.cFileName
.TextMatrix(.Rows - 1, 2) = StringDateTime(lpData.ftCreationTime)
.TextMatrix(.Rows - 1, 3) = StringDateTime(lpData.ftLastAccessTime)
.TextMatrix(.Rows - 1, 4) = StringDateTime(lpData.ftLastWriteTime)
.TextMatrix(.Rows - 1, 5) = Hex(lpData.dwFileAttributes)
.TextMatrix(.Rows - 1, 6) = lpData.nFileSizeLow
End With
Loop
Call InternetCloseHandle(hFind)
lbFTPEnum = Grid.Rows - 1
End Function
| |