3) FILETIME データの取得

  API 定義



  
' ------------------------------------------------------
' 日付処理用
' ------------------------------------------------------
Type SYSTEMTIME
        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
End Type

Declare Function FileTimeToSystemTime Lib "kernel32" ( _
    lpFiletime As FILETIME, _
    lpSystemTime As SYSTEMTIME _
) As Long

  



  FILETIME を 文字列に変換する関数



  
' ******************************************************
' FILETIMEを文字列に変換
' ******************************************************
Public Function StringDateTime(lpFiletime As FILETIME) As String
    
    Dim lpSystemTime As SYSTEMTIME

    Call FileTimeToSystemTime(lpFiletime, lpSystemTime)
    
    StringDateTime = _
        Format(lpSystemTime.wYear, "0000") & "/" & _
        Format(lpSystemTime.wMonth, "00") & "/" & _
        Format(lpSystemTime.wDay, "00") & " " & _
        Format(lpSystemTime.wHour, "00") & ":" & _
        Format(lpSystemTime.wMinute, "00") & ":" & _
        Format(lpSystemTime.wSecond, "00")

End Function

  



  一覧の取得を変更

  
' ******************************************************
' 一覧の取得
' ******************************************************
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 = 5
    Grid.Rows = 2

    With Grid
        .TextMatrix(0, 1) = "FileName"
        .TextMatrix(0, 2) = "CreationTime"
        .TextMatrix(0, 3) = "LastAccessTime"
        .TextMatrix(0, 4) = "LastWriteTime"
    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)
        End With

    Loop

    Call InternetCloseHandle(hFind)
    
    lbFTPEnum = Grid.Rows - 1

End Function

  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ