Zitat von
Karstadt:
kann ich das irgenwie "auslesen" wenn es mit der obengenannte function nicht geht?
Die Funktion hat einen Rückgabewert.
Ansonsten probiere es damit
Delphi-Quellcode:
function GetLocalFileTimes(const FileName: string; out Created, Accessed, Modified: TDateTime): Boolean;
var
FileHandle: THandle;
CreationTime: TFileTime;
LastAccessTime: TFileTime;
LastWriteTime: TFileTime;
LocalCreationTime: TFileTime;
LocalLastAccessTime: TFileTime;
LocalLastWriteTime: TFileTime;
SystemCreationTime: TSystemTime;
SystemLastAccessTime: TSystemTime;
SystemLastWriteTime: TSystemTime;
begin
Result := False;
FileHandle := CreateFile(PChar(FileName), GENERIC_READ, FILE_SHARE_READ or
FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, THandle(nil));
if FileHandle <> INVALID_HANDLE_VALUE then
try
if GetFileTime(FileHandle, @CreationTime, @LastAccessTime, @LastWriteTime) and
FileTimeToLocalFileTime(CreationTime, LocalCreationTime) and
FileTimeToLocalFileTime(LastAccessTime, LocalLastAccessTime) and
FileTimeToLocalFileTime(LastWriteTime, LocalLastWriteTime) and
FileTimeToSystemTime(LocalCreationTime, SystemCreationTime) and
FileTimeToSystemTime(LocalLastAccessTime, SystemLastAccessTime) and
FileTimeToSystemTime(LocalLastWriteTime, SystemLastWriteTime) then
begin
try
Created := SystemTimeToDateTime(SystemCreationTime);
Accessed := SystemTimeToDateTime(SystemLastAccessTime);
Modified := SystemTimeToDateTime(SystemLastWriteTime);
Result := True;
except
// ignore exceptions;
end;
end;
finally
CloseHandle(FileHandle);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Created: TDateTime;
Accessed: TDateTime;
Modified: TDateTime;
begin
if GetLocalFileTimes(ParamStr(0), Created, Accessed, Modified) then
ShowMessage(
'Created: ' + DateTimeToStr(Created) + #13#10 +
'Accessed: ' + DateTimeToStr(Accessed) + #13#10 +
'Modified: ' + DateTimeToStr(Modified));
end;
BTW: Nicht alle Dateisysteme unterstüzen alle drei Zeiten...