Get File 'Last Modified' attribute

CK CK 3788 
Created at
Updated at  
466 0 0

This function is useful to get file attribute.

Usage:
 

label1.Caption:=FileLastModified('c:autoexec.bat') ;



In addition, below function must be included in order to use above function.
 

function FileLastModified(const TheFile: string): string;
var
  FileH : THandle;
  LocalFT : TFileTime;
  DosFT : DWORD;
  LastAccessedTime : TDateTime;
  FindData : TWin32FindData;
begin
  Result := '';
  FileH := FindFirstFile(PChar(TheFile), FindData) ;
  if FileH <> INVALID_HANDLE_VALUE then begin
   Windows.FindClose(Handle) ;
   if (FindData.dwFileAttributes AND
       FILE_ATTRIBUTE_DIRECTORY) = 0 then
    begin
     FileTimeToLocalFileTime
      (FindData.ftLastWriteTime,LocalFT) ;
     FileTimeToDosDateTime
      (LocalFT,LongRec(DosFT).Hi,LongRec(DosFT).Lo) ;
     LastAccessedTime := FileDateToDateTime(DosFT) ;
     Result := DateTimeToStr(LastAccessedTime) ;
    end;
  end;
end;
Tags ChangeFileExt FILE_ATTRIBUTE_DIRECTORY File I/O Status Check FileTimeToDosDateTime FindFirstFile Facebook X
Comments 0
Similar posts
  1. From/to the 8.3 (short) format to/from the long format
    581
  2. Delete folders recursively
    423
  3. How to Split and Merge Files
    621
  4. Path shortener: c:\ABC...DEF.ghi
    443
  5. Reading a directory content
    443
  6. Delete files with the ability to UNDO
    439
  7. Does my CD-ROM drive contain an audio CD?
    364
  8. Convert a mapped drive to a full UNC path
    833
  9. Checking If File Is In Use
    922
  1. Paint a Form with a tiled bitmap image
    413
  2. Is Point in Polygon?
    368
  3. Implementing a lasso drawing technique
    384
  4. Grayscaling a bitmap ?
    532
  5. Get Cursor Image (draw it on a Canvas)
    681
  6. How to convert HIcon to TIcon ?
    448
  7. Extract an icon from an Windows application and paint on a Form
    416
  8. How to draw transparent text on Windows Desktop
    415
  9. How to draw rotated text
    1,333
  10. How to convert an ICO to a BMP
    363
  11. How to Convert Pixels to Millimeters
    622
  12. How to capture Windows Desktop to Bitmap
    560
  13. Cut a rectangle from an Image to Clipboard
    538
  14. Convert TColor to Hex & Hex to TColor
    592
  15. Convert a BMP to a JPG
    410
  16. Browse for Computers, Folders, Files and Printers
    571
  17. How to draw Transparent Text on bitmap
    386
  18. How Do I Remove The Application Icon From The Taskbar?
    1,099
  19. How To Show The Print Dialog And Print Text Files
    1,295
  20. How To Make An Animated Application Icon
    820
  21. How To Pass The Focus To The Next/prior Control
    1,210
  22. How To Make Rounded Windows
    1,227
  23. How To Get Windows Uptime
    1,479
  24. How To Find Out Total And Available Memory
    1,642
  25. How To Change The System Time
    1,254
  26. How To Get The Windows OS Version
    618
  27. How To Change The Desktop Wallpaper
    2,153
  28. How To Get The Windows Language
    1,147
  29. How To Make A Gradient Filled Form
    839
  30. How can I hide the caption bar on a form?
    1,398
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    42
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    36
  3. How do I create animated background for Google Meet?
    21,017
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    251
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    515
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    288
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    232
  16. TPU & GPU Cluster Management Tools
    245
  17. The Concept of Scaffolding in AI Agents
    234
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    259
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    222
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    221
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    196
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    219
  30. Understanding Data Lineage
    262