你好快呀
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 
   );var
h: thandle;
d1,d2,d3: tdatetime;
begin
  h:=openfile('e:\hh.txt');
  Getfiletime(h,d1,d2,d3)
//d1,d2,d3反回时间
end;

解决方案 »

  1.   

    同意。
    BOOL GetFileTime(
      HANDLE hFile,                 // handle to file
      LPFILETIME lpCreationTime,    // 创建时间
      LPFILETIME lpLastAccessTime,  // 最后一次访问时间   lpLastWriteTime    // 最后一次读
    );
      

  2.   

    openfile参数怎么写?第二个和第三个
      

  3.   

    得到了LPFILETIME ,怎么取成字符串?
      

  4.   

    {these record structures allow for easy manipulation of Dos
       date and time values}
      TDosTime=Record
        Hour      : Byte;
        Minutes   : Byte;
        seconds   : Byte;
      end;  TDosDate = Record
        Year   : Word;
        Month  : Byte;
        Day    : Byte;
      end;var
      Form1: TForm1;
      hFile: THandle;            // a handle to the opened fileimplementation{this function provides a convenient way to convert a Dos time into its component parts}
    function ConvertDosTimeToSystemTime(FileDosTime: WORD): TDosTime;
    var
      DosTime: TDosTime;
    begin
      DosTime.Seconds := (FileDosTime and $1F) * 2;
      DosTime.Minutes := (FileDosTime and $7E0) shr 5;
      DosTime.Hour    := (FileDosTime and $F800) shr 11;
      Result          := DosTime;
    end;{this function provides a convenient way to convert a
     Dos date into its component parts}function ConvertDosDateToSystemDate(FileDosDate: WORD): TDosDate;
    var
      DosDate: TDosDate;
    begin
      DosDate.Day   := FileDosDate and $1F;
      DosDate.Month := FileDosDate and $1E0 shr 5;
      DosDate.Year  := (FileDosDate and $FE00) shr 9 + 1980;
      Result        := DosDate;
    end;procedure TForm1.SpeedButton2Click(Sender: TObject);
    var
      Security: TSecurityAttributes;        // attributes for the opened file  FileName: PChar;                      // holds the filename
      WriteTime, LocalTime: TFILETIME;      // holds file times
      DosDate, DosTime: WORD;               // holds the Dos date and time
      infoDosTime: TDosTime;                // holds Dos time information
      infoDosDate: TDosDate;                // holds Dos date information
      SystemTime: TSystemTime;              // holds the last modification timebegin
      {setup the security attributes for the opened file}
      Security.nLength := SizeOf(TSecurityAttributes);
      Security.lpSecurityDescriptor := nil;
      Security.bInheritHandle := FALSE;  {display the open dialog box}
      if OpenDialog1.Execute then
      begin
        {display the selected filename...}
        FileName := PChar(OpenDialog1.FileName);
        StatusBar1.SimpleText := FileName;    {...and open it}    hFile := CreateFile(PChar(FileName),GENERIC_READ or GENERIC_WRITE,
                            FILE_SHARE_READ or FILE_SHARE_WRITE, @Security,
                            OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);    {if there was an error, show a message}
        if hFile = INVALID_HANDLE_VALUE then
        begin
          ShowMessage('Error Opening File');
          Exit;
        end;
      end;  {retrieve the last modification time}  GetFileTime(hFile, nil, nil, @WriteTime);  {convert the time to local file time}
      FileTimeToLocalFileTime(WriteTime, LocalTime);  {finally, convert the time to the system time, so that it
       will match the file time displayed in the Explorer}
      FileTimeToSystemTime(LocalTime, SystemTime);  {convert the file time into Dos date and time components...}
      FileTimeToDosDateTime(LocalTime, DosDate, DosTime);  {...and convert it back}  if not DosDateTimeToFileTime(DosDate, DosTime, LocalTime) then
        ShowMessage ('An error occured when converting Dos date and time back to'+
                     ' file time.');  {break out the component parts of the Dos date and time for easy display}
      infoDosTime := ConvertDosTimeToSystemTime(DosTime);
      infoDosDate := ConvertDosDateToSystemDate(DosDate);  with infoDosTime do
        Edit1.Text := ComboBox1.Items[infoDosDate.Month - 1]+ ' ' +                  IntToStr(infoDosDate.Day) + ',' +
                      IntToStr(infoDosDate.Year) + '  ' +
                      IntToStr(Hour) + ':' +
                      IntToStr(Minutes) + ':' +
                      IntToStr(Seconds) ;  {indicate the time of day}
      case SystemTime.WHour of
        12        : Label1.Caption := 'PM';
        13..24    : begin
                      Label1.Caption := 'PM';
                      SystemTime.wHour:=SystemTime.wHour - 12;                end;
        0         : SystemTime.wHour:= 12;
      else
        Label1.Caption := 'AM';
      end;  {display the last modification time of the file}
      SpinEdit1.Value     := SystemTime.wYear;
      SpinEdit2.Value     := SystemTime.wHour;
      SpinEdit3.Value     := SystemTime.wMinute;
      SpinEdit4.Value     := SystemTime.wSecond;
      ComboBox1.ItemIndex := SystemTime.wMonth - 1;
      Calendar1.Month     := SystemTime.wMonth;
      Calendar1.Day       := SystemTime.wDay;end;procedure TForm1.SpeedButton3Click(Sender: TObject);
    var
      FileTime, LocalFileTime: TFileTime;  // holds file times
      SystemTime: TSystemTime;             // holds system time information
    begin
      {prepare the time information from the values set by the user}
      SystemTime.wHour   := SpinEdit2.Value;  if (Label1.Caption = 'PM') and (SystemTime.wHour < 12) then
          SystemTime.wHour := SystemTime.wHour + 12;  SystemTime.wMinute := SpinEdit3.Value;
      SystemTime.wSecond := SpinEdit4.Value;
      SystemTime.wYear   := SpinEdit1.Value;
      SystemTime.wMonth  := ComboBox1.ItemIndex + 1;
      SystemTime.wDay    := Calendar1.Day;  {convert the system time to a local file time}
      SystemTimeToFileTime(SystemTime,LocalFileTime);  {convert the local file time to a file time that the file system understands}
      LocalFileTimeToFileTime(LocalFileTime,FileTime);  {use this time to set the last modification time which shows
       up in the Explorer}
      SetFileTime(hFile, nil, nil, @FileTime);
    end;
      

  5.   

    procdeure GetFileTime(const Tf:string);
    { 获取文件时间,Tf表示目标文件路径和名称 }
    const
    Model='yyyy/mm/dd,hh:mm:ss'; { 设定时间格式 }
    var
    Tp:TSearchRec; { 申明Tp为一个查找记录 }
    T1,T2,T3:string;begin
    FindFirst(Tf,faAnyFile,Tp); { 查找目标文件 } T1:=FormatDateTime(Model,
    CovFileDate(Tp.FindData.ftCreationTime)));
    { 返回文件的创建时间 }
    T2:=FormatDateTime(Model,
    CovFileDate(Tp.FindData.ftLastWriteTime)));
    { 返回文件的修改时间 }
    T3:=FormatDateTime(Model,Now));
    { 返回文件的当前访问时间 }
    FindClose(Tp);
    end;