Hi,
in FilePath steht der Pfad für die Datei, von der das Erstellungsdatum ermittelt werden soll (z.B. C:/Temp/...).
Die Script-Klasse, welche ich verwende sieht folgendermaßen aus:
Const INVALID_HANDLE_VALUE = -1
Const MAX_PATH = 260
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Type WIN32_FIND_DATA
dwFileAttributes As Long ' Dateiattribute
ftCreationTime As FILETIME ' Erstellungsdatum
ftLastAccessTime As FILETIME ' Letzter Zugriff
ftLastWriteTime As FILETIME ' Letzte Speicherung
nFileSizeHigh As Long ' Größe (Hi)
nFileSizeLow As Long ' Größe (Lo)
dwReserved0 As Long ' bedeutungslos
dwReserved1 As Long ' bedeutungslos
cFileName As String * MAX_PATH ' Dateiname
cAlternate As String * 14 ' 8.3-Dateiname
End Type
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 FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (Byval lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (Byval hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindClose Lib "kernel32" (Byval hFindFile As Long) As Long
Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Class FileInfo
Public Function GetFileTimeInfo ( strPath As String , MODE As Integer ) As String
Dim FileHandle As Long
Dim FileData As WIN32_FIND_DATA
Dim LocalFileTime As FILETIME
Dim LocalSystemTime As SYSTEMTIME
FileHandle = FindFirstFile(strPath & vbNullChar, FileData)
Select Case MODE
Case 0
FileTimeToLocalFileTime FileData.ftLastAccessTime, LocalFileTime
Case 1
FileTimeToLocalFileTime FileData.ftLastWriteTime, LocalFileTime
Case 2
FileTimeToLocalFileTime FileData.ftCreationTime, LocalFileTime
End Select
FileTimeToSystemTime LocalFileTime, LocalSystemTime
GetFileTimeInfo = _
Left$(FileData.cFileName, Instr(FileData.cFileName, vbNullChar) - 1) _
& LocalSystemTime.wDay & "." _
& LocalSystemTime.wMonth & "." _
& LocalSystemTime.wYear & ", "_
& LocalSystemTime.wHour & ":" _
& Format$(LocalSystemTime.wMinute, "00") _
& ":" & Format$(LocalSystemTime.wSecond, "00") & " Uhr"
FindClose FileHandle
End Function
Public Function GetFileInfo ( strPath As String , MODE As Integer ) As String
Dim FileHandle As Long
Dim FileData As WIN32_FIND_DATA
FileHandle = FindFirstFile ( strPath & vbNullChar , FileData )
If FileHandle <> INVALID_HANDLE_VALUE Then
Select Case MODE
Case 3
GetFileInfo = FileData.cFileName
Case 4
GetFileInfo = Cstr(FileData.nFileSizeLow)
Case 5
GetFileInfo = FileData.cFileName
Case 6
GetFileInfo = Cstr(FileData.dwFileAttributes)
Case 7
GetFileInfo = Cstr(FileData.cAlternate)
End Select
End If
FindClose FileHandle
End Function
End Class
Also mit MODE = 2 hole ich mir das Erstellungsdatum.
Diese Script-Klasse habe ich in eine Script Bibliothek eingefügt. Diese wiederum habe ich mit Use "Name der Bibliothek" zum Agenten hinzugefügt (wie auch bei einer normalen Bibliothek mit Lotus-Script-Code).
Habe es auch schon mal probiert, wenn ich die Klasse direkt in den Agenten hineinkopiere (also ohne Use).
Gleicher Fall : Irgendwie kann er auf dem Server die WinAPI-Funktion nicht ausführen.
Gruss
Martin