You can read the linker timestamp from the PE header of the executable:
uses
ImageHlp;
function LinkerTimeStamp(const FileName: string): TDateTime; overload;
var
LI: TLoadedImage;
begin
Win32Check(MapAndLoad(PChar(FileName), nil, @LI, False, True));
Result := LI.FileHeader.FileHeader.TimeDateStamp / SecsPerDay + UnixDateDelta;
UnMapAndLoad(@LI);
end;
For the loaded image of the current module, the following seems to work:
function LinkerTimestamp: TDateTime; overload;
begin
Result := PImageNtHeaders(HInstance + Cardinal(PImageDosHeader(HInstance)^._lfanew))^.FileHeader.TimeDateStamp / SecsPerDay + UnixDateDelta;
end;
Earlier versions of Delphi didn't update it correctly but it has been fixed around Delphi 2010 or so. For the earlier versions, I used an IDE plugin to update it automatically after a successful compile.
Note: The value is stored as UTC so for display purposes you may need to convert it to an appropriate timezone.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…