1.BOOL GetFileTime(    HANDLE hFile, // identifies the file 
    LPFILETIME lpCreationTime, // address of creation time 
    LPFILETIME lpLastAccessTime, // address of last access time  
    LPFILETIME lpLastWriteTime  // address of last write time 
   );
HELP里有的
2、formatdatetime('yyyy-mm-dd',now)

解决方案 »

  1.   

    对不起,我要得是具体例子。如果我要得到d:\aa.dat文件的最后修改时间,api
    应怎么写?(我对api不熟)
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      hFile: THandle;
      iFileDate: Integer;
    begin
      if Not FileExists(Edit1.Text) then
        Raise Exception.Create('文件不存在!');  hFile := FileOpen(Edit1.Text, fmOpenRead);
      if hFile = INVALID_HANDLE_VALUE then
        Raise Exception.Create('打开文件有错');  try
        iFileDate := FileGetDate(hFile);
        if iFileDate <> -1 then
          ShowMessage('最后一次修改时间: ' + FormatDateTime('yyyy-mm-dd hh:mm:ss', FileDateToDateTime(iFileDate)));
      finally
        FileClose(hFile);
      end;
    end;