datetimescriptinginno-setuppascaldatestamp

Getting the last modification date of a file in Inno Setup Pascal Script


I need to choose the most recently modified file in my installation script. It seems the Pascal scripting language has no GetFileDateTime or similar, so I am resorting to:

function FileDateTime (FileID : string) : double ;

var
   FindRec        : TFindRec;

begin
    Result := 0.00 ;
    if (FindFirst (FileID, FindRec)) then
        begin
        try
            Result := FindRec.LastWriteTime ;  { gives type mismatch, naturally }
        finally
            FindClose (FindRec) ;
        end ;
    end ;
end ;

but I can't find any documentation on the format of LastWriteTime. Ideally I want the datetime returned in a format that will make it relatively easy to display it, as I will need to write the equivalent of Delphi's FormatDateTime as well. Inno Pascal has GetDateTimeString but this only formats the current datetime, not an arbitrary datetime.


Solution

  • The documentation on the TFindRec record in InnoSetup is here. It is very sparse, but I am almost confident that it has the exact same format as the corresponding structure in the Windows API.

    Indeed, InnoSetup's FindFirst function most likely corresponds to FindFirstFile of the Windows API. Thus, the TFindRec record corresponds to the WIN32_FIND_DATA structure so that a TFileTime record corresponds to a FILETIME structure.