|
Source Code -
Inno Setup
|
|
Written by Thomas
|
|
Monday, 01 June 2009 19:30 |
|
Page 2 of 4
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.
var ProgressPage: TOutputProgressWizardPage; ProgressValue: Integer; ArrayLen: LongInt; procedure ProcessDirectory (RootDir: String; Progress: Boolean); var NewRoot: String; FilePath: String; FindRec: TFindRec; begin NewRoot := AddBackSlash (RootDir); if FindFirst (NewRoot + '*', FindRec) then begin try repeat if (FindRec.Name <> '.') AND (FindRec.Name <> '..') then begin FilePath := NewRoot + FindRec.Name; if FindRec.Attributes AND FILE_ATTRIBUTE_DIRECTORY > 0 then ProcessDirectory (FilePath, Progress) else begin // Start action --> // . // Add your custom code here. // FilePath contains the file name // including its full path name. // Try not to call a function for every file // as this could take a very long time. // . // <-- End action. ArrayLen := ArrayLen + 1; if (Progress) then begin if (ArrayLen mod 1000) = (ArrayLen / 1000) then begin ProgressValue := ProgressValue + 1; if ProgressValue = 100 then ProgressValue := 0; ProgressPage.SetProgress (ProgressValue, 100); end; end; end; end; until NOT FindNext (FindRec); finally FindClose(FindRec); end; end; end; procedure CurStepChanged (CurStep: TSetupStep); var lI: LongInt; Dir: String; begin if (CurStep = ssInstall) then begin // The folder to scan. Dir := 'C:\'; // The progress page. ProgressPage := CreateOutputProgressPage (CustomMessage ('ProgressTitle'), CustomMessage ('ProgressCaption')); ProgressPage.SetText (CustomMessage ('ProgressText'), Dir); ProgressPage.SetProgress(0, 0); ProgressPage.Show; // Scan the folder. ProcessDirectory (Dir, TRUE); // Hide the progress page. try finally ProgressPage.Hide; end; end; end;
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 |
to post comments.