ViaThinkSoft CodeLib
This article is in:
CodeLib → Programming aids → Delphi
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
ViaThinkSoft Co-Founder