Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

last access time

Posted on 1997-12-01
3
Medium Priority
?
189 Views
Last Modified: 2011-04-14
Here's a very simple question...
how do I get the last access time of a file

I know that to get the last write time it's:
Fsearchrec.finddata.ftlastwritetime

But I don't have my reference book with me and I would appreciate it if someone could tell me what last access time is for Tsearchrec

Tsearchrec.findata.????

Thanks
0
Comment
Question by:rafy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1352626
Hi

The following routine shows the create, access and write times of autoexec.bat.  It uses a routine called "FileTimeToDateTime" which I have included below.

procedure TForm1.Button1Click(Sender: TObject);
var
    fs: TFileStream;
    ftCreate, ftAccess, ftWrite: TFileTime;
    dtCreate, dtAccess, dtWrite: TDateTime;
begin
    fs := TFileStream.Create('C:\AutoExec.bat', fmOpenRead or fmShareDenyNone);
    try
        GetFileTime(fs.Handle, @ftCreate, @ftAccess, @ftWrite);

        dtCreate := FileTimeToDateTime(ftCreate);
        dtAccess := FileTimeToDateTime(ftAccess);
        dtWrite := FileTimeToDateTime(ftWrite);

        ShowMessage('Create: ' + DateTimeToStr(dtCreate));
        ShowMessage('Access: ' + DateTimeToStr(dtAccess));
        ShowMessage('Write: ' + DateTimeToStr(dtWrite));
    finally
        fs.Free;
    end;
end;

function FileTimeToDateTime(AFileTime: TFileTime): TDateTime;
var
    FatDate, FatTime: Word;
    ADay, AMonth, AYear, ASec, AMin, AHour: Word;
begin
    FileTimeToDOSDateTime(AFileTime, FatDate, FatTime);
    ADay := (FatDate and 31);
    AMonth := (FatDate and 480) shr 5;
    AYear := ((FatDate and 65024) shr 9) + 1980;
    ASec := (FatTime and 31) * 2;
    AMin := (FatTime and 2016) shr 5;
    AHour := ((FatTime and 63488) shr 11);
    Result := EncodeDate(AYear, AMonth, ADay) + EncodeTime(AHour, AMin, ASec, 0);
end;

Regards,
JB
0
 

Author Comment

by:rafy
ID: 1352627
Thanks, but I already have my code written up using the windows Tsearchrec Data type, all I want is the field for last access time....it's an old program that I want to modify, not one I want to rewrite

It's probably something like Tsearchrec.finddata.ftlastaccess??

all I need is the last part...Thanks again
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 200 total points
ID: 1352628
Sorry, I misunderstood you.

Yes, TSearchRec's FindData has (inter alia) ftCreationTime, ftLastAccessTime and ftLastWriteTime.

JB
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question