Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:02:59+00:00 2026-06-02T00:02:59+00:00

In my installer I’m extracting files from archives that don’t store time/date attributes, so

  • 0

In my installer I’m extracting files from archives that don’t store time/date attributes, so when they’re extracted the last modified date is set to the current date. I would like to set it to the last modified date of the archive file but I can’t figure out how. I tried using pieces of the code from here and here but while it didn’t give any errors, it didn’t work for changing the time. Last modified date would need to be changed for * .* in a folder.

Also, where do I need to hook into to delete these files if the user cancels setup and it starts rolling back changes? I’ve got it taken care of in UninstallDelete but not if the user cancels setup.

EDIT: Disregard the second part, I actually figured it out shortly after I posted here. Added my own CleanUp() to DeinitializeSetup() with a check for the uninstaller registry key.

Here is the section of code I’m trying to add it to:

procedure VolExtract(VWorld: String);
var
  ResultCode: Integer;
  VPath: String;
begin
  // Files are extracted to {app}\VWorld\One, {app}\VWorld\Two, etc.
  VPath := ExpandConstant('{app}\' + VWorld);
  WizardForm.FilenameLabel.Caption := DriveLetter + VWorld + '\one.vol';
  if Exec(ExpandConstant('{tmp}\volextract.exe'), '"' + DriveLetter + VWorld + '\one.vol" "' + VPath + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then
  begin
    // Yep, it executed successfully
    WizardForm.FilenameLabel.Caption := DriveLetter + VWorld + '\two.vol';
    if Exec(ExpandConstant('{tmp}\volextract.exe'), '"' + DriveLetter + VWorld + '\two.vol" "' + VPath + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then
    begin
      // Next
      WizardForm.FilenameLabel.Caption := DriveLetter + VWorld + '\three.vol';
      if Exec(ExpandConstant('{tmp}\volextract.exe'), '"' + DriveLetter + VWorld + '\three.vol" "' + VPath + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then
      begin
        // Next
        WizardForm.FilenameLabel.Caption := DriveLetter + VWorld + '\four.vol';
        Exec(ExpandConstant('{tmp}\volextract.exe'), '"' + DriveLetter + VWorld + '\four.vol" "' + VPath + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
      end;
    end;
  end;
  if ResultCode <> 0 then
  begin
    // Handle Fail
    CDFound := False;
    MsgBox(CustomMessage('FileErr'), mbInformation, MB_OK);
    WizardForm.Close;
  end;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:03:00+00:00Added an answer on June 2, 2026 at 12:03 am

    To change the last modified time (let’s call it LastWriteTime for now) for all files from a specified directory by the LastWriteTime of a certain file, use the following code after you have your files extracted. You can follow the commented version of the previous version of this post, but note that I’ve had bugs there (mixed time parameters and unused file flag parameter), but the point remains.

    Also note that this code is for ANSI version of InnoSetup. If you need to use this for Unicode version, you should define the CreateFile function import as CreateFileW instead of CreateFileA or use the trick suggested by kobik in this post.

    [code]
    const
      OPEN_EXISTING = 3;  
      FILE_SHARE_WRITE = 2;
      GENERIC_WRITE = $40000000;
      INVALID_HANDLE_VALUE = 4294967295;
    
    function CreateFile(lpFileName: string; dwDesiredAccess, dwShareMode,
      lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes: DWORD;
      hTemplateFile: THandle): THandle; 
      external 'CreateFileA@kernel32.dll stdcall';
    function CloseHandle(hObject: THandle): BOOL; 
      external 'CloseHandle@kernel32.dll stdcall';
    function SetFileTime(hFile: THandle; const lpCreationTime, lpLastAccessTime, 
      lpLastWriteTime: TFileTime): BOOL; 
      external 'SetFileTime@kernel32.dll stdcall';
    
    function FileSetTime(const AFileName: string; const ACreationTime, 
      ALastAccessTime, ALastWriteTime: TFileTime): Boolean;
    var
      FileHandle: THandle;
    begin
      Result := False;
      FileHandle := CreateFile(AFileName, GENERIC_WRITE, FILE_SHARE_WRITE, 0,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
      if FileHandle <> INVALID_HANDLE_VALUE then
      try
        Result := SetFileTime(FileHandle, ACreationTime, ALastAccessTime, 
          ALastWriteTime);
      finally
        CloseHandle(FileHandle);
      end;
    end; 
    
    procedure ModifyLastWriteTime(const ASourceFile, ATargetFolder: string);
    var
      FindRec: TFindRec;
      LastWriteTime: TFileTime;
    begin
      if FindFirst(ASourceFile, FindRec) then
      begin
        LastWriteTime := FindRec.LastWriteTime;
        if FindFirst(ATargetFolder + '*.*', FindRec) then
        try
          repeat
            if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
              FileSetTime(ATargetFolder + FindRec.Name, FindRec.CreationTime, 
                FindRec.LastAccessTime, LastWriteTime);
          until
            not FindNext(FindRec);
        finally
          FindClose(FindRec);
        end;
      end;
    end;
    

    And the usage. The first parameter of the ModifyLastWriteTime procedure is the name of the source file from which the LastWriteTime is taken. The second parameter is the directory in what the files will get modified their LastWriteTime values by the source file (don’t forget to have the trailing backslash in the target folder parameter):

    ModifyLastWriteTime('c:\SourceFile.xxx', 'c:\TargetFolder\')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating an installer for possible remote systems so that if they do not have
Our installer allows the users to select where they want to install certain files,
I have built an installer using WiX that consists of multiple .exe files that
I have a windows installer (MSI) project. I want to ensure that when i
We have an installer application. In that we have one dll related to our
I have an installer for which I don't have any source code. I need
I have an installer that needs to a person to be an admin (
My installer installs the app to Program files\MyApp, the app when running changes files
The installer insist that I have Visual Studio 2005 installed. This brings me to
I have a NSIS installer that installs my non-Metro application on Windows 8. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.