Gehe zu deutscher Webseite

ViaThinkSoft CodeLib

This article is in:
CodeLibProgramming aidsDelphi

function GetOwnBuildTimestamp: TDateTime;
var
  fs: TFileStream;
  unixTime: integer;
  peOffset: Integer;
begin
  try
    fs := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
    try
      fs.Seek($3C, soFromBeginning);
      fs.Read(peOffset, 4);

      fs.Seek(peOffset+8, soFromBeginning);
      fs.Read(unixTime, 4);

      // TODO: If required, convert UTC zu your local time zone.
      result := UnixToDateTime(unixTime); // requires DateUtils
    finally
      FreeAndNil(fs);
    end;
  except
    // Should not happen
    FileAge(ParamStr(0), result);
  end;
end;
Daniel Marschall
ViaThinkSoft Co-Founder

Feedback? Problems? Please drop us a message!

Your name (optional):

E-mail address (optional):

Message: