I'm using this code to capture compilation date of a executable (.exe). I'm searching a solution to achieve the same to a .dll file. When this code is inserted in a dll project and injected/or using exported function in some executable (.exe), the compilation date retrieved is of executable and not of dll.
function GetExeBuildTime: TDateTime;
var
LI: TLoadedImage;
{$IF CompilerVersion >= 26.0}
m: TMarshaller;
{$IFEND}
timeStamp: Cardinal;
utcTime: TDateTime;
begin
{$IF CompilerVersion >= 26.0}
Win32Check(MapAndLoad(PAnsiChar(m.AsAnsi(ParamStr(0)).ToPointer), nil, @LI,
False, True));
{$ELSE}
Win32Check(MapAndLoad(PAnsiChar(AnsiString(ParamStr(0))), nil, @LI,
False, True));
{$IFEND}
timeStamp := LI.FileHeader.FileHeader.TimeDateStamp;
UnMapAndLoad(@LI);
utcTime := UnixToDateTime(timeStamp);
Result := TTimeZone.local.ToLocalTime(utcTime);
end;
Usage:
FormatDateTime('dd/mm/yyyy', GetExeBuildTime);