Files in use extension


(Difference between revisions)
Jump to: navigation, search
m (added category Process Functions)
Line 75: Line 75:
[[Category:Web references, resources and links]]
[[Category:Web references, resources and links]]
[[Category:Process functions]]

Revision as of 07:36, 28 March 2007

Files-In-Use functionality is among the countless services that Windows Installer exposes for setup authors to leverage for their application install/maintenance. This functionality lets setup authors display the processes that hold on to files that would be updated by this install. The user would want to shut those processes before continuing with the install to ensure that the install wouldn’t require a reboot. You can do the same thing with Inno Setup avoiding unnecessary reboots when installing your application exe files / plugin / shell extension / ocx etc with [Files-In-Use Extension for Inno Setup]



- small size (it will add less than 20KB to your setup. The uncompressed DLL is about 55KB )

- multiple modules search (a semicolon list with exe/dll/ocx names can be used)

- applications exe names will be listed not just their window captions

- easy to use

How do I get it to work with Inno?

1. Download [Files-In-Use Extension for Inno Setup]

2. Add the extension (IssProc.dll) in your [Files] section script :

Sample code

      Source: IssProc.dll; DestDir: {tmp}; Flags: dontcopy 

3. Add below code in your [Code] section script (you ca modify it as you like):

Sample code

      function IssFindModule(hWnd: Integer; Modulename: PChar): Integer;
      external ‘IssFindModule@files:IssProc.dll stdcall’;

      function NextButtonClick(CurPage: Integer): Boolean;
        hWnd: Integer;
        sModuleName: String;
        nCode: Integer;  {IssFindModule returns: 0 if no module found; 1 if cancel pressed; 2 if ignore pressed; -1 if an error occured }
        Result := true;

       if CurPage = wpReady then
            Result := false;
            hWnd := StrToInt(ExpandConstant(‘{wizardhwnd}’));      { get main wizard handle }
            sModuleName := ‘kernel32.dll;gen_trill.dll;gen_ml.dll’;             { searched module. Tip: separate multiple modules by ; Ex: ‘mymodule.dll;mymodule2.dll;mymodule3.dll’}

           nCode:=IssFindModule(hWnd,sModuleName);                 { search for module and display files-in-use window if found  }

           if nCode=1 then  begin                                  { cancel pressed or files-in-use window closed }
                PostMessage (WizardForm.Handle, $0010, 0, 0);      { quit setup, $0010=WM_CLOSE }
           end else if (nCode=0) or (nCode=2) then begin           { no module found or ignored pressed}
                Result := true;                                    { continue setup  }

           { warn user when ignored pressed? }
           { else if (nCode=2) then begin
              if MsgBox(‘The setup will continue but it may require to reboot your computer after the installation in order to replace files that are in use. Are you sure?’, mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then
                 Result := true;



4. Set sModuleName from the above code with your own modules names (separate multiple modules with semicolon)

5. Compile and test your setup. Before Inno will begin install operation The File In Use Extension will check if your modules (DLL’s/exe’s/ocx’s names) are in use and it will popup with a window asking the user to close those applications. The user can choose to Ignore this and continue with setup rebooting at the end, or he can close those applications and click on Retry.

Personal tools