文件时间var
  hf: THandle;
  tC, tA, tW: TFileTime;
  sC, sA, sW: TSystemTime;
begin
  hf := CreateFile('d:\1.bmp', GENERIC_READ, 0, nil, OPEN_EXISTING, 0, 0);
  getfiletime(hf, @tC, @tA, @tW);
  CloseHandle(hf);
  FileTimeToSystemTime(tC, sC);
  FileTimeToSystemTime(tA, sA);
  FileTimeToSystemTime(tW, sW);
  showmessage(inttostr(sC.wYear) + ':' + inttostr(sc.wMonth) + ':' + inttostr(sc.wDay) + #13 +
              inttostr(sA.wYear) + ':' + inttostr(sA.wMonth) + ':' + inttostr(sA.wDay) + #13 +
              inttostr(sW.wYear) + ':' + inttostr(sW.wMonth) + ':' + inttostr(sW.wDay));
系统时间  参见上面

解决方案 »

  1.   

    var
      LocalTime:TSystemTime;                //本地系统时间变量
      FileTime_Creat:TFileTime;             //文件建立时间
      FileTime_LastAccess:TFileTime;        //最后一次访问时间
      FileTime_LastWrite:TFileTime;         //最后一次更改时间
      LsTime:TDateTime;                     //临时时间变量
      pofFile:THandle;                      //文件句柄
    begin
    GetlocalTime(LocalTime);
    LsTime:=SystemTimeToDateTime(LocalTime);
    Label2.Caption:='本地时间:'+DateToStr(LsTime)+'  '+TimeToStr(LsTime);pofFile:=CreateFile('c:\winzip.log', GENERIC_READ, 0, nil, OPEN_EXISTING, 0, 0);
    GetFileTime(pofFile,@FileTime_Creat,@FileTime_LastAccess,@FileTime_LastWrite);
    CloseHandle(pofFile);
      

  2.   

    const
      FILE_CREATE_TIME=0;
      FILE_Modify_Time=1;
    ......
    function GetFileLastAccessTime(sFileName:string;uFlag:byte):TDateTime;
    var
      ffd:TWin32FindData;
      dft:DWord;
      lft:TFileTime;
      h:THandle;
    begin
      h:=FindFirstFile(PChar(sFileName),ffd);
      if h<>INVALID_HANDLE_VALUE then
      begin
      case uFlag of
      FILE_CREATE_TIME:FileTimeToLocalFileTime(ffd.ftCreationTime,lft);
      FILE_MODIFY_TIME:FileTimeToLocalFileTime(ffd.ftLastWriteTime,lft);
      FILE_ACCESS_TIME:FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
      else
        FileTimeToLocalFileTime(ffd.ftLastAccessTime,lft);
      end;
      FileTimeToDosDateTime(lft,LongRec(dft).Hi,LongRec(dft).Lo);
      Result:=FileDateToDateTime(dft);
      windows.FindClose(h);
      end
      else
      result:=0;
    end;
      

  3.   

    有啊,我用的是fans2000的代码,到底是什么问题 ??
      

  4.   

    没办法了,只有告诉你杀手锏了!你在每一个API后用showmessage(inttostr(GetLasterror));
    看哪一句后显示的不是 0;即是这一句有错
      

  5.   

    我用了getlasterror()显示的值如下,请帮我分析一下错误原因,谢谢 !pofFile:=CreateFile('c:\winzip.log', GENERIC_READ, 0, nil, OPEN_EXISTING, 0, 0);
    showmessage(inttostr(GetLasterror)); getlasterror=32GetFileTime(pofFile,@FileTime_Creat,@FileTime_LastAccess,@FileTime_LastWrite);
    showmessage(inttostr(GetLasterror)); getlasterror=6CloseHandle(pofFile);
    showmessage(inttostr(GetLasterror)); getlasterror=6
      

  6.   

    查Help->Windows SDK->"errors"Error Code:
      32L       ERROR_SHARING_VIOLATION;  文件共享错误
      6L        ERROR_INVALID_HANDLE   ;  没打开文件自然句柄无效CreateFile第三个参数设为 FILE_SHARE_READ 试试
      

  7.   

    用GetFileAttributeEx好了,即简单又不用打开文件!