Raz-Soft » Blog Archive » Files-In-Use Extension for Inno Setup
Spammers, ahh… ii urasc! m-am saturat de spam asa ca… »
« Westlife The Rose

Files-In-Use Extension for Inno Setup

  First of all I would like to give a big thanks to Jordan Russell for the best freeware installer for Windows programs: Inno Setup. If you need to deploy your applications this is the best free tool you will find, trust me. If you don't want to write script by hand you can always use ISTool to edit these scripts faster in a visual and easy environment.

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.

Now you can do the same thing with Inno Setup avoiding unnecessary reboots when installing your application exe files / plugin / shell extension / ocx etc with My Files In Use Extension for Inno Setup
Features:

  • small size (it will add less than 20KB to your setup. )
  • multi-language support (you can add or modify the language file)

100% FREE AWARD

  • multiple file search (a semicolon list with exe/dll/ocx names and path can be used)
  • wildcard file match ( * = matches any characters, zero or more times ; ? = matches any character, one time )
  • exact folder match (detect if your file is in use only from a specified folder )
  • applications exe names will be listed not just their description
  • both 32 and 64 bit applications detection (Vista & XP x64 )
  • user friendly: applications are displayed along with their icon
  • possibility to end the detected process forcedly (right click on process for more options)
  • easy to use and 100% free

How do I get it to work with Inno?
1. Download latest File In Use Extension for Inno (IssProc.dll and Inno script demo included)
2. Add the extension (IssProc.dll) in your [Files] section script :

INNO:
  1. [Files]
  2. ;------ add Files In Use Extension
  3. Source: IssProc.dll; DestDir: {tmp}; Flags: dontcopy
  4. ;------ add Files In Use Extension extra language file (you don t need to add this file if you are using english only)
  5. Source: IssProcLanguage.ini; DestDir: {tmp}; Flags: dontcopy
  6. ;------ Copy IssProc.dll in your app folder if you want to use it on unistall
  7. Source: IssProc.dll; DestDir: {app}
  8. Source: IssProcLanguage.ini; DestDir: {app}
  9. ;------

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

PASCAL:
  1. [Code]
  2. // IssFindModule called on install
  3. function IssFindModule(hWnd: Integer; Modulename: PChar; Language: PChar; Silent: Boolean; CanIgnore: Boolean ): Integer;
  4. external 'IssFindModule@files:IssProc.dll stdcall setuponly';
  5.  
  6. // IssFindModule called on uninstall
  7. function IssFindModuleU(hWnd: Integer; Modulename: PChar; Language: PChar; Silent: Boolean; CanIgnore: Boolean ): Integer;
  8. external 'IssFindModule@{app}\IssProc.dll stdcall uninstallonly';
  9.  
  10. //********************************************************************************************************************************************
  11. // IssFindModule function returns: 0 if no module found; 1 if cancel pressed; 2 if ignore pressed; -1 if an error occured
  12. //
  13. //  hWnd        = main wizard window handle.
  14. //
  15. //  Modulename  = module name(s) to check. You can use a full path to a DLL/EXE/OCX or wildcard file name/path. Separate multiple modules with semicolon.
  16. //                 Example1 : Modulename='*mymodule.dll';     -  will search in any path for mymodule.dll
  17. //                 Example2 : Modulename=ExpandConstant('{app}\mymodule.dll');     -  will search for mymodule.dll only in {app} folder (the application directory)
  18. //                 Example3 : Modulename=ExpandConstant('{app}\mymodule.dll;*myApp.exe');   - just like Example2 + search for myApp.exe regardless of his path.
  19. //
  20. //  Language    = files in use language dialog. Set this value to empty '' and default english will be used
  21. //                ( see and include IssProcLanguage.ini if you need custom text or other language)
  22. //
  23. //  Silent      = silent mode : set this var to true if you don't want to display the files in use dialog.
  24. //                When Silent is true IssFindModule will return 1 if it founds the Modulename or 0 if nothing found
  25. //
  26. //  CanIgnore   = set this var to false to Disable the Ignore button forcing the user to close those applications before continuing
  27. //                set this var to true to Enable the Ignore button allowing the user to continue without closing those applications
  28. //******************************************************************************************************************************************
  29.  
  30.  
  31. function NextButtonClick(CurPage: Integer): Boolean;
  32. var
  33.   hWnd: Integer;
  34.   sModuleName: String;
  35.   nCode: Integer{IssFindModule returns: 0 if no module found; 1 if cancel pressed; 2 if ignore pressed; -1 if an error occured }
  36. begin
  37.   Result := true;
  38.  
  39.  if CurPage = wpReady then
  40.    begin
  41.       Result := false;
  42.       ExtractTemporaryFile('IssProcLanguage.ini');                          { extract extra language file - you don't need to add this line if you are using english only }
  43.       hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));                     { get main wizard handle }
  44.       sModuleName :=ExpandConstant('{app}\Myprog.exe');                     { searched modules. Tip: separate multiple modules with semicolon Ex: '*mymodule.dll;*mymodule2.dll;*mymodule3.dll'}
  45.  
  46.      nCode:=IssFindModule(hWnd,sModuleName,'en',false,true);                { search for module and display files-in-use window if found  }
  47.      //sModuleName:=IntToStr(nCode);
  48.     // MsgBox ( sModuleName, mbConfirmation, MB_YESNO or MB_DEFBUTTON2);
  49.  
  50.      if nCode=1 then  begin                                                 { cancel pressed or files-in-use window closed }
  51.           PostMessage (WizardForm.Handle, $0010, 0, 0);                     { quit setup, $0010=WM_CLOSE }
  52.      end else if (nCode=0) or (nCode=2) then begin                          { no module found or ignored pressed}
  53.           Result := true;                                                   { continue setup  }
  54.      end;
  55.  
  56.   end;
  57.  
  58. end;
  59.  
  60.  
  61. function InitializeUninstall(): Boolean;
  62. var
  63.   sModuleName: String;
  64.   nCode: Integer{IssFindModule returns: 0 if no module found; 1 if cancel pressed; 2 if ignore pressed; -1 if an error occured }
  65.  
  66. begin
  67.     Result := false;
  68.       sModuleName := ExpandConstant('*Myprog.exe;');    { searched module. Tip: separate multiple modules with semicolon Ex: '*mymodule.dll;*mymodule2.dll;*myapp.exe'}
  69.  
  70.      nCode:=IssFindModuleU(0,sModuleName,'enu',false,false); { search for module and display files-in-use window if found  }
  71.  
  72.      if (nCode=0) or (nCode=2) then begin                    { no module found or ignored pressed}
  73.           Result := true;                                    { continue setup  }
  74.      end;
  75.  
  76.     // Unload the extension, otherwise it will not be deleted by the uninstaller
  77.     UnloadDLL(ExpandConstant('{app}\IssProc.dll'));
  78.  
  79. end;

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.

Version History

Download

Who's Using IssProc?

related things:

Author: Raz | On March 17th, 2007 | [ En ], - Raz-Soft News | 13 Comments

Q: So what can I do next?
A: You can Buy me a Beer or Coffee. You can say Hi! or peek on the related stuff. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

    13 Responses to “Files-In-Use Extension for Inno Setup”

  1. George ROMANIA Says:

    Hi,
    Is there a way to translate the popup window asking the user to close those applications? I need a translation for a germany setup file.
    Thanks


  2. Raz ROMANIA Says:

    Hi George,
    The popup window is in English and there is no multi-language support for now, but multi-lang support is scheduled to be added in the next build.
    Thanks


  3. Raz ROMANIA Says:

    Multi-language support added in IssProc.dll v1.0.1


  4. Crulex UKRAINE Says:

    My installation fails under Vista Enterprise x64, as well as the sample setup I've compiled from your sample.
    I'm getting the following error immediately after launching setup:
    ---------------------------
    Runtime Error (at -1:0):

    Cannot Import dll:C:\TEMP\is-SL00G.tmp\IssProc.dll.
    ---------------------------
    I tried changing the script to delay load your dll but it stll fails during the installation.
    On Win98/2000/WinXP anything goes fine.
    I wonder it might be smth with manifests, etc.


  5. Raz ROMANIA Says:

    Hi Crulex,
    It looks like Inno Setup cannot Import the DLL in Vista Enterprise x64. I guess the only thing that causes the failure is the extension packer (used to reduce the size). The only thing I can do is to send you the unpacked version of the extension, you can download it from here
    Please let me know if the unpacked version works on your installlation.


  6. Mark AUSTRALIA Says:

    I am using your unpacked version on Vista 64 Business edition as the other one wont work. If possible could you please add detection of 64 bit programs?


  7. Crulex UKRAINE Says:

    Hi Raz,
    Thanks for the feedback, I've just needed to resolve this issue today.
    The unpacked version works very well on my Vista x64 installation.
    I've found that the packed version installs correctly if I turn off DEP on my Vista installation by running the following command from the command prompt with administrative privileges:

    bcdedit.exe /set {current} nx AlwaysOff

    It seems that a lot of the execiutable packers are incompatible with DEP :(


  8. Raz ROMANIA Says:

    Hi all,
    IssProc v1.0.2 is out: no more packer and DEP problems (i hope), support for both 32 & 64 apps, fully tested on XP and Vista x64 and more user friendly. Let me know your thoughts ;)
    Thank you


  9. Neo BELGIUM Says:

    Hi,

    During install in english we can see on the main form 'Setup - My Program' and in french 'Installation - My program' ... great !

    But during uninstall in english we can see on the main form 'Setup' and in french 'setup'

    It should be great during uninstall to see in english 'Setup - My Program' and in french 'Désinstallation - My Program' like in inno setup !

    I do not really understand how to add a second language in the code (french and english). Could you give me an example please ?

    I've translated the IssProcLanguage.ini file in french. If you want this one email me please

    Thanks for all

    Neo


  10. Raz ROMANIA Says:

    Hi Neo,
    For now caption on install/uninstall can not be set from language file but I will add that on my "to do list".

    For your translation: in the file IssProcLanguage.ini file create a section called [fr] (used on install ) and [fru] (unsinstall) and add your translated variables just like those in english, something like this (you can copy the below code and translate):

    ;***** [French language] Install ****
    [fr]
    ; *** Labels ***
    TopBoldLabel=Files in use
    TopSubLabel=Some files that needed to be updated are currently in use.
    MoreInfoLabel=The following applications are using files that need to be updated by this setup. Close these applications and then click Retry to continue the installation or Cancel to exit it.
    ;*** Buttons ***
    CancelButton=&Cancel
    IgnoreButton=&Ignore
    RetryButton=&Retry

    ;**[French language] Uninstall ***********
    [fru]
    ; *** Labels ***
    TopBoldLabel=Files in use
    TopSubLabel=Some files that needed to be removed are currently in use.
    MoreInfoLabel=The following applications are using files that need to be removed by this setup. Close these applications and then click Retry to continue uninstalling or Cancel to exit it.
    ;*** Buttons ***
    CancelButton=&Cancel
    IgnoreButton=&Ignore
    RetryButton=&Retry

    After you add (and translate) the above sections use "fr" and "fru" for language param of IssProc function like this:

    nCode:=IssFindModule(hWnd,sModuleName,'fr',false,true);

    and on uninstall like this:

    nCode:=IssFindModule(hWnd,sModuleName,'fru',false,true);

    Please send you translation file at: razvar .at. gmail .dot. com and I will reply you with the working/modified french one.

    Thanks


  11. Neo BELGIUM Says:

    Hi,

    Yes working great with : nCode:=IssFindModule(hWnd,sModuleName,'fr',false,true);

    and : nCode:=IssFindModule(hWnd,sModuleName,'fru',false,true);

    But in fact I use innosetup in multi language in my case the users select english or french during the first screen !

    And right now I just can use IssProc in english or french but not the both.

    I hope you understand what I mean !

    Neo


  12. Raz Says:

    Hi Neo,

     You must modify your script and put additional checks: If the user has selected the english language then use IssProg with 'en' value on the language param. If it selects french then use IssProc with 'fr' and so on...You must have some experience with inno script (delphi/pascal) to make that work.

     I can help you out with that too, but right now time is not on my side. Send me your script (attach the language file as well) and I shall modify it for you one more time  :-?

    Raz


  13. Daniel UNITED STATES Says:

    Hi,

    Is it possible to get the name and icon of the file-in-use from the app's main window, instead of getting it from the FileVersion info? This is what Task Manager does for the "Applications" tab, as it is generally more useful/correct than just the FileVersion info.

    The exact problem I'm having is this: when the file-in-use is a Java app, IssProc will display something like "Java (TM) 2 Platform Standard Edition binary (javaw.exe)" with the ugly default icon. Of course, most users have no idea what that is!

    I think that getting the icon and name from the FileVersion info is a good backup strategy for processes that don't have any windows.

    Thanks for a nice utility!

    Daniel


Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> and all YM emotions