Contenu
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Rechercher
Login
Qui est en ligne?
Nous avons 247 invités en ligne
Navigation
Home Code source Inno Setup Scan a disk path or an entire disk with Inno Setup
Les plus récents
Articles vedettes
Joomla 1.5 Featured Articles
Navigation
Home Code source Inno Setup Scan a disk path or an entire disk with Inno Setup
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Scan a disk path or an entire disk with Inno Setup Envoyer
Note des utilisateurs: / 11
MauvaisTrès bien 
Code source - Inno Setup
Écrit par Thomas   
Lundi, 01 Juin 2009 19:30
Index de l'article
Scan a disk path or an entire disk with Inno Setup
Progress page
Cancel button
Example script
Toutes les pages

 

For an installation program I wanted to give the user an option to automatically scan for a particular file on his hard drive or maybe only in a subtree of a drive.

A search through the Inno Setup newsgroups brings up several posts to discourage people to do so. It is understandable, because network and local drives could contain several million files or a similar amount of folders. It could take hours to read the directory tree in and search for a single file. The reasonable alternative is to find the file through other clues like registry entries.

However, the location of the file my installation program is supposed to look for is stored nowhere. The software saves its settings in a Windows ini file, and this file resides just next to the executable file in the same folder.

 

Preparing the Inno Setup script to search for it in a given folder tree or an entire drive seems helpful to the user.

It didn't even look very complicated as the helpfile has a pretty good example on how to use the functions FirndFirst and FindNext. The only minor obstacle was my limited Pascal knowledge which had become a bit rusty over the years, and of course because Inno Setup's Pascal script is not comparable with a fully-featured Pascal compiler.

That's probably the reason why my first attempt didn't want to work on larger directory trees. I kept getting an 'Out of memory' message after a few seconds. I had tried to read the tree into a string array (TArrayOfString) by dynamically expanding it as files and folder names where coming in from the tree reading function. I wanted a flexible function to read the folder tree and then go through the array and process every single file and directory in a second step outside that reading function.

  1. procedure ProcessDirectory (RootDir: String; Progress: Boolean);
  2. var
  3. NewRoot:        String;
  4. FilePath:        String;
  5. FindRec:        TFindRec;
  6. begin
  7. NewRoot := AddBackSlash (RootDir);
  8. if FindFirst (NewRoot + '*', FindRec) then
  9. begin
  10. try
  11. repeat
  12. if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then
  13. begin
  14. FilePath := NewRoot + FindRec.Name;
  15. if FindRec.Attributes AND FILE_ATTRIBUTE_DIRECTORY > 0 then
  16. ReadDirectory (FilePath, Progress)
  17. else
  18. begin
  19. // Start action -->
  20. // .
  21. // Add your custom code here.
  22. // FilePath contains the file name
  23. // including its full path name.
  24. // Try not to call a function for every file
  25. // as this could take a very long time.
  26. // .
  27. // <-- End action.
  28. end;
  29. end;
  30. until NOT FindNext (FindRec);
  31. finally
  32. FindClose(FindRec);
  33. end;
  34. end;
  35. end;
  36.  
  37.  

When this function is called, the installer can't do anything else. In effect, that means that not even the installation wizard's window can be moved. The user interface blocks completely without feeding anything back.

 



Mise à jour le Jeudi, 15 Octobre 2009 15:26
 
You need to login or register to post comments.
Discutez de ceci sur le forum. (5 posts)
Discutez de (5 posts)
Re: Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 20:10:17
Not sure I understand what a "registry directory" is
#2352
Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 17:13:28
hi
this above scanning drive inno setup code can be use just like installaing files to registry directory
#2351
Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 17:11:28
#2350
Scan a disk path or an entire disk with Inno Setup
Apr 02 2018 17:11:28
hi
this above scanning drive inno setup code can be use just like installaing files to registry directory
#2349
Scan a disk path or an entire disk with Inno Setup
Sep 25 2012 06:22:16
This is very helpful post. Thanks for this dude. It really helps me a lot.

*** some spam removed *** (by George)
#1454