Delphi 得到文件创建时间、修改时间、访问时间

procedure TForm1.Button1Click(Sender: TObject);

var

FileOp : TOFStruct ;

FHandle : THandle ;

FInfo : TByHandleFileInformation ;

dtCreate : TSystemTime;

Temp:_FileTime;

begin

memo1.clear;

setlasterror(20);

FHandle:= openfile(pchar(edit1.text),FileOp ,OF_READ);

GetFileInformationByHandle(FHandle,FInfo);

memo1.Lines.Add('File Attributes : '+inttostr(FInfo.dwFileAttributes));

FileTimeToLocalFileTime(FInfo.ftCreationTime,Temp);

FileTimeToSystemTime(Temp,dtCreate);

memo1.Lines.Add('File Create Time : '

+inttostr(dtCreate.wYear)+'-'

+inttostr(dtCreate.wMonth)+'-'

+inttostr(dtCreate.wDay)+' '

+inttostr(dtCreate.wHour)+':'

+inttostr(dtCreate.wMinute)+':'

+inttostr(dtCreate.wSecond) );

FileTimeToLocalFileTime(FInfo.ftLastAccessTime,Temp);

FileTimeToSystemTime(Temp,dtCreate);

memo1.Lines.Add('File Last Access Time : '

+inttostr(dtCreate.wYear)+'-'

+inttostr(dtCreate.wMonth)+'-'

+inttostr(dtCreate.wDay)+' '

+inttostr(dtCreate.wHour)+':'

+inttostr(dtCreate.wMinute)+':'

+inttostr(dtCreate.wSecond) );

FileTimeToLocalFileTime(FInfo.ftLastWriteTime,Temp);

FileTimeToSystemTime(Temp,dtCreate);

memo1.Lines.Add('File Last Write Time : '

+inttostr(dtCreate.wYear)+'-'

+inttostr(dtCreate.wMonth)+'-'

+inttostr(dtCreate.wDay)+' '

+inttostr(dtCreate.wHour)+':'

+inttostr(dtCreate.wMinute)+':'

+inttostr(dtCreate.wSecond) );

memo1.Lines.Add('File Path and Name : '+FileOp.szPathName);

_lclose(FHandle);