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 - Example script
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 - Example script
English (United Kingdom)French (Fr)Deutsch (DE-CH-AT)
Scan a disk path or an entire disk with Inno Setup - Example script 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

 

Here's the example script:

Open ReadDirectoryTree.iss
 

ReadDirectoryTree.iss:

  1. ; Script generated by the Inno Setup Script Wizard.
  2. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
  3.  
  4. #define MyAppName "My Program"
  5. #define MyAppVerName "My Program 1.5"
  6. #define MyAppPublisher "My Company, Inc."
  7. #define MyAppURL "http://www.example.com/"
  8. #define MyAppExeName "MyProg.exe"
  9.  
  10. [Setup]
  11. ; NOTE: The value of AppId uniquely identifies this application.
  12. ; Do not use the same AppId value in installers for other applications.
  13. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
  14. AppId={{753F2C1F-EA02-488E-A204-A047F1EFA0BC}
  15. AppName={#MyAppName}
  16. AppVerName={#MyAppVerName}
  17. AppPublisher={#MyAppPublisher}
  18. AppPublisherURL={#MyAppURL}
  19. AppSupportURL={#MyAppURL}
  20. AppUpdatesURL={#MyAppURL}
  21. DefaultDirName={pf}\{#MyAppName}
  22. DefaultGroupName={#MyAppName}
  23. OutputBaseFilename=setup
  24. Compression=lzma
  25. SolidCompression=yes
  26.  
  27. [Languages]
  28. Name: english; MessagesFile: compiler:Default.isl
  29.  
  30. [CustomMessages]
  31. english.ProgressTitle=Searching
  32. english.ProgressCaption=Searching for files
  33. english.ProgressText=Searching for files...
  34.  
  35. [Code]
  36. var
  37. ProgressPage: TOutputProgressWizardPage;
  38. ProgressValue: Integer;
  39. ArrayLen: LongInt;
  40. bExitSetup: Boolean;
  41.  
  42. procedure ProcessDirectory (RootDir: String; Progress: Boolean);
  43. var
  44. NewRoot: String;
  45. FilePath: String;
  46. FindRec: TFindRec;
  47. begin
  48. if bExitSetup then
  49. Exit;
  50. NewRoot := AddBackSlash (RootDir);
  51. if FindFirst (NewRoot + '*', FindRec) then
  52. begin
  53. try
  54. repeat
  55. if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then
  56. begin
  57. FilePath := NewRoot + FindRec.Name;
  58. if FindRec.Attributes AND FILE_ATTRIBUTE_DIRECTORY > 0 then
  59. ProcessDirectory (FilePath, Progress)
  60. else
  61. begin
  62. // Start action -->
  63. // .
  64. // Add your custom code here.
  65. // FilePath contains the file name
  66. // including its full path name.
  67. // Try not to call a function for every file
  68. // as this could take a very long time.
  69. // .
  70. // <-- End action.
  71. ArrayLen := ArrayLen + 1;
  72. if (Progress) then
  73. begin
  74. if (ArrayLen mod 1000) = (ArrayLen / 1000) then
  75. begin
  76. ProgressValue := ProgressValue + 1;
  77. if ProgressValue = 100 then
  78. ProgressValue := 0;
  79. ProgressPage.SetProgress (ProgressValue, 100);
  80. end;
  81. end;
  82. end;
  83. end;
  84. if (bExitSetup) then
  85. Exit;
  86. until NOT FindNext (FindRec);
  87. finally
  88. FindClose(FindRec);
  89. end;
  90. end;
  91. end;
  92.  
  93. function MessageBox (hWnd: Integer; lpText, lpCaption: String; uType: Cardinal): Integer;
  94. external 'MessageBoxA@user32.dll stdcall';
  95.  
  96. procedure CancelButtonClick (CurPageID: Integer; var Cancel, Confirm: Boolean);
  97. begin
  98. Confirm := FALSE;
  99. if (MessageBox (0, SetupMessage (msgExitSetupMessage),
  100. SetupMessage (msgExitSetupTitle), 4 + 32) = 6) then
  101. begin
  102. bExitSetup := TRUE;
  103. end;
  104. end;
  105.  
  106. procedure CurStepChanged (CurStep: TSetupStep);
  107. var
  108. lI: LongInt;
  109. Dir: String;
  110. begin
  111. if (CurStep = ssInstall) then
  112. begin
  113. // The folder to scan.
  114. Dir := 'C:\';
  115. // The progress page.
  116. ProgressPage := CreateOutputProgressPage (CustomMessage ('ProgressTitle'),
  117. CustomMessage ('ProgressCaption'));
  118. ProgressPage.SetText (CustomMessage ('ProgressText'), Dir);
  119. ProgressPage.SetProgress(0, 0);
  120. ProgressPage.Show;
  121. // Make the Cancel button visible during the operation.
  122. ;WizardForm.CancelButton.Visible := TRUE;
  123. // Scan the folder.
  124. ProcessDirectory (Dir, TRUE);
  125. // Hide the progress page.
  126. try
  127. finally
  128. ProgressPage.Hide;
  129. end;
  130. end;
  131. end;
  132.  
  133.  
Open ReadDirectoryTree.iss

 



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