Contents
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Search
Login
Who Is Online?
We have 83 guests online
Navigation
Home Source Code Inno Setup Scan a disk path or an entire disk with Inno Setup - Progress page
Most Recent
Featured Articles
Joomla 1.5 Featured Articles
Navigation
Home Source Code Inno Setup Scan a disk path or an entire disk with Inno Setup - Progress page
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Scan a disk path or an entire disk with Inno Setup - Progress page E-mail
User Rating: / 11
PoorBest 
Source Code - Inno Setup
Written by Thomas   
Monday, 01 June 2009 19:30
Article Index
Scan a disk path or an entire disk with Inno Setup
Progress page
Cancel button
Example script
All Pages

 

In order to show at least something in Inno Setup's wizard, a progress page can be inserted. Reading and processing a directory tree is a serial operation, meaning that it's finishing time can't be predicted in advance. This is why I set the progress bar up to change its status every 1000 files or folders, and when it has hit the right side of the bar it rolls over to the left again.

  1. var
  2. ProgressPage:    TOutputProgressWizardPage;
  3. ProgressValue:    Integer;
  4. ArrayLen:        LongInt;
  5.  
  6. procedure ProcessDirectory (RootDir: String; Progress: Boolean);
  7. var
  8. NewRoot:        String;
  9. FilePath:        String;
  10. FindRec:        TFindRec;
  11. begin
  12. NewRoot := AddBackSlash (RootDir);
  13. if FindFirst (NewRoot + '*', FindRec) then
  14. begin
  15. try
  16. repeat
  17. if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then
  18. begin
  19. FilePath := NewRoot + FindRec.Name;
  20. if FindRec.Attributes AND FILE_ATTRIBUTE_DIRECTORY > 0 then
  21. ProcessDirectory (FilePath, Progress)
  22. else
  23. begin
  24. // Start action -->
  25. // .
  26. // Add your custom code here.
  27. // FilePath contains the file name
  28. // including its full path name.
  29. // Try not to call a function for every file
  30. // as this could take a very long time.
  31. // .
  32. // <-- End action.
  33. ArrayLen := ArrayLen + 1;
  34. if (Progress) then
  35. begin
  36. if (ArrayLen mod 1000) = (ArrayLen / 1000) then
  37. begin
  38. ProgressValue := ProgressValue + 1;
  39. if ProgressValue = 100 then
  40. ProgressValue := 0;
  41. ProgressPage.SetProgress (ProgressValue, 100);
  42. end;
  43. end;
  44. end;
  45. end;
  46. until NOT FindNext (FindRec);
  47. finally
  48. FindClose(FindRec);
  49. end;
  50. end;
  51. end;
  52.  
  53. procedure CurStepChanged (CurStep: TSetupStep);
  54. var
  55. lI:            LongInt;
  56. Dir:        String;
  57. begin
  58. if (CurStep = ssInstall) then
  59. begin
  60. // The folder to scan.
  61. Dir := 'C:\';
  62. // The progress page.
  63. ProgressPage := CreateOutputProgressPage (CustomMessage ('ProgressTitle'),
  64. CustomMessage ('ProgressCaption'));
  65. ProgressPage.SetText (CustomMessage ('ProgressText'), Dir);
  66. ProgressPage.SetProgress(0, 0);
  67. ProgressPage.Show;
  68. // Scan the folder.
  69. ProcessDirectory (Dir, TRUE);
  70. // Hide the progress page.
  71. try
  72. finally
  73. ProgressPage.Hide;
  74. end;
  75. end;
  76. end;
  77.  

With the progress bar moving, the installation program gained a nice touch towards the standards of what people expect from a fashionate installer. Saying that, this is however only on the surface. There is no chance for the user to interrupt the disk scan unless they use the Taskmanager and kill the setup process.

 



Last Updated on Thursday, 15 October 2009 15:26
 
You need to login or register to post comments.
Discuss this item on the forums. (5 posts)
Discuss (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