Files-In-Use Extension for Inno Setup

Posted on the March 17th, 2007 under Raz-Soft News, [ En ] by Raz

  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 :

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
[Code]
// IssFindModule called on install
function IssFindModule(hWnd: Integer; Modulename: PChar; Language: PChar; Silent: Boolean; CanIgnore: Boolean ): Integer;
external 'IssFindModule@files:IssProc.dll stdcall setuponly';

// IssFindModule called on uninstall
function IssFindModuleU(hWnd: Integer; Modulename: PChar; Language: PChar; Silent: Boolean; CanIgnore: Boolean ): Integer;
external 'IssFindModule@{app}\IssProc.dll stdcall uninstallonly';

//********************************************************************************************************************************************
// IssFindModule function returns: 0 if no module found; 1 if cancel pressed; 2 if ignore pressed; -1 if an error occured
//
//  hWnd        = main wizard window handle.
//
//  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.
//                 Example1 : Modulename='*mymodule.dll';     -  will search in any path for mymodule.dll
//                 Example2 : Modulename=ExpandConstant('{app}\mymodule.dll');     -  will search for mymodule.dll only in {app} folder (the application directory)
//                 Example3 : Modulename=ExpandConstant('{app}\mymodule.dll;*myApp.exe');   - just like Example2 + search for myApp.exe regardless of his path.
//
//  Language    = files in use language dialog. Set this value to empty '' and default english will be used
//                ( see and include IssProcLanguage.ini if you need custom text or other language)
//
//  Silent      = silent mode : set this var to true if you don't want to display the files in use dialog.
//                When Silent is true IssFindModule will return 1 if it founds the Modulename or 0 if nothing found
//
//  CanIgnore   = set this var to false to Disable the Ignore button forcing the user to close those applications before continuing
//                set this var to true to Enable the Ignore button allowing the user to continue without closing those applications
//******************************************************************************************************************************************


function NextButtonClick(CurPage: Integer): Boolean;
var
  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 }
begin
  Result := true;

 if CurPage = wpReady then
   begin
      Result := false;
      ExtractTemporaryFile('IssProcLanguage.ini');                          { extract extra language file - you don't need to add this line if you are using english only }
      hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));                     { get main wizard handle }
      sModuleName :=ExpandConstant('{app}\Myprog.exe');                     { searched modules. Tip: separate multiple modules with semicolon Ex: '*mymodule.dll;*mymodule2.dll;*mymodule3.dll'}

     nCode:=IssFindModule(hWnd,sModuleName,'en',false,true);                { search for module and display files-in-use window if found  }
     //sModuleName:=IntToStr(nCode);
    // MsgBox ( sModuleName, mbConfirmation, MB_YESNO or MB_DEFBUTTON2);

     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  }
     end;

  end;

end;


function InitializeUninstall(): Boolean;
var
  sModuleName: String;
  nCode: Integer;  {IssFindModule returns: 0 if no module found; 1 if cancel pressed; 2 if ignore pressed; -1 if an error occured }

begin
    Result := false;
      sModuleName := ExpandConstant('*Myprog.exe;');    { searched module. Tip: separate multiple modules with semicolon Ex: '*mymodule.dll;*mymodule2.dll;*myapp.exe'}

     nCode:=IssFindModuleU(0,sModuleName,'enu',false,false); { search for module and display files-in-use window if found  }

     if (nCode=0) or (nCode=2) then begin                    { no module found or ignored pressed}
          Result := true;                                    { continue setup  }
     end;

    // Unload the extension, otherwise it will not be deleted by the uninstaller
    UnloadDLL(ExpandConstant('{app}\IssProc.dll'));

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.

Notes: Starting with Inno Setup v5.3.0 script the ‘PChar’ type has been renamed to ‘PAnsiChar’. Just Replace all occurrences of ‘PChar’ type to ‘PAnsiChar’ in the above example if you are using InnoSetup v5.3 or newer.

Version History

Download

Who’s Using IssProc?

42 Responses to 'Files-In-Use Extension for Inno Setup'

  1. April 7, 2007 at 11:22 am
    George
  2. April 7, 2007 at 12:29 pm
    Raz
  3. April 15, 2007 at 10:33 pm
    Raz
  4. July 7, 2007 at 11:06 am
    Crulex
  5. July 7, 2007 at 11:32 am
    Raz
  6. July 12, 2007 at 4:23 am
    Mark
  7. July 12, 2007 at 12:41 pm
    Crulex
  8. September 25, 2007 at 9:55 am
    Raz
  9. November 13, 2007 at 1:45 pm
    Neo
  10. November 13, 2007 at 2:27 pm
    Raz
  11. November 13, 2007 at 3:42 pm
    Neo
  12. November 15, 2007 at 7:55 pm
    Raz
  13. May 17, 2008 at 1:37 am
    Daniel
  14. November 17, 2008 at 4:03 am
    Mitchell
    • May 11, 2009 at 8:38 am
      Raz
  15. November 21, 2008 at 3:31 pm
    Alexander
  16. January 20, 2009 at 8:18 am
    Syam S
    • May 11, 2009 at 8:40 am
      Raz
      • November 30, 2009 at 6:13 am
        Xeek
  17. February 13, 2009 at 5:36 am
    Vaz
    • May 11, 2009 at 8:40 am
      Raz
  18. April 21, 2009 at 11:16 pm
    sg
    • May 11, 2009 at 8:43 am
      Raz
  19. May 10, 2009 at 12:35 am
    Clark L
    • May 11, 2009 at 8:34 am
      Raz
  20. June 29, 2009 at 8:15 pm
    mlodyno
    • September 1, 2009 at 9:24 am
      Raz
  21. July 21, 2009 at 1:49 am
    Brandon
    • September 1, 2009 at 2:32 am
      Clark L
  22. September 1, 2009 at 9:26 am
    Raz
  23. September 5, 2009 at 5:23 pm
    Brandon
    • September 7, 2009 at 4:54 pm
      Raz
  24. September 7, 2009 at 4:22 pm
    Brandon
    • September 7, 2009 at 5:09 pm
      Raz
  25. November 8, 2009 at 12:32 am
    David
  26. November 10, 2009 at 4:55 am
    Miguel Vivanco
  27. November 18, 2009 at 5:33 am
    Kite
  28. December 7, 2009 at 4:29 pm
    zakyn
    • December 8, 2009 at 5:00 pm
      Raz
      • January 14, 2010 at 4:02 pm
        zeroG
  29. December 22, 2009 at 9:45 pm
    TStarGermany
  30. September 11, 2009 at 5:50 pm
    Clark L

Leave a Reply

Skip, ignore me





XHTML::
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>