Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to retrieve a file's "Last Accessed" attribute Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
15-Sep-02
Category
Files Operation
Language
Delphi 2.x
Views
127
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

Retrieve a file's "Last Accessed" attribute

Answer:

In Windows 95, you can see when a file was last accessed by right-clicking the file 
and selecting properties. You can retrieve this date easily with the following 
ready-to-use function:
1   
2   function LastAccess(const filename: string): string;
3   var
4     FileHandle: THandle;
5     LocalFileTime: TFileTime;
6     DosFileTime: DWORD;
7     LastAccessedTime: TDateTime;
8     FindData: TWin32FindData;
9   begin
10    Result := ''; { never :-) }
11    FileHandle := FindFirstFile(filename, FindData);
12    if FileHandle <> INVALID_HANDLE_VALUE then
13    begin
14      Windows.FindClose(Handle);
15      if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
16      begin
17        FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
18        FileTimeToDosDateTime(LocalFileTime,
19          LongRec(DosFileTime).Hi, LongRec(DosFileTime).Lo);
20        LastAccessedTime := FileDateToDateTime(DosFileTime);
21        Result := DateTimeToStr(LastAccessedTime);
22      end;
23    end;
24  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC