This article Reprinted from: http://blog.csdn.net/yushanddddfenghailin/article/details/17250933
Event functions (2)
Function checkpassword (password: string): Boolean;
If the installer finds this function in the Pascal script, it automatically displays the password page and calls checkpassword to check the password. If true is returned, the password is accepted. If false is returned, the password is rejected. The test code is as follows:
Function checkpassword (password: string): Boolean; Begin If Password = 'castor' then Result: = true; End; |
The installation password is displayed during the installation process. If an error is entered, the following dialog box is displayed:
To avoid storing real passwords in the [Code] field, it is best to use other information for comparison. For example, use getmd5ofstring (password) to calculate the MD5 value of the actual password to protect the actual password.
Function needrestart (): Boolean;
If true is returned, the installer prompts you to restart the system at the end of the installation process. If false, no prompt is displayed. The test code is as follows:
Function needrestart (): Boolean; Begin Result: = true; End; |
After the installation is complete, the following options will appear on the Finish page:
Function updatereadymemo (space, newline, memouserinfoinfo, memodirinfo, memotypeinfo, memocomponentsinfo, memogroupinfo, memotasksinfo: string): string;
If the function exists in the script, the function is automatically called when the ready to install page is changed to the activity page. The function returns a piece of text, this text is displayed in the setting remarks on the ready to install page, and the text is separated into multiple lines by the newline parameter. The parameter space refers to space, and the test is six, other parameters will contain characters (which may be null) that the installer uses to set segments ). For example, the memodirinfo parameter contains the string of the selected directory segment. The test code is as follows:
Function updatereadymemo (space, newline, memouserinfoinfo, memodirinfo, memotypeinfo, memocomponentsinfo, memocomponentsinfo, memotasksinfo: string): string; VaR Res: string; Begin Res: = 'updatereadymemo function is here '+ newline + 'this is the second line '; Res: = res + space + 'and with six spaces '; Res: = res + newline + 'memouserinfoinfoinfo' + memouserinfoinfo; Res: = res + newline + 'memodirinfo' + memodirinfo; Res: = res + newline + 'memotypeinfo' + memotypeinfo; Res: = res + newline + 'memocomponentsinfo' + memocomponentsinfo; Res: = res + newline + 'memocomponentsinfo' + memocomponentsinfo; Res: = res + newline + 'memotasksinfo '+ memotasksinfo; Result: = res; End; |
After running, the confirmation page is displayed before installation:
Mark the content of each parameter in the yellow text.
Procedure registerpreviusdata (previusdatakey: integer );
This process stores user input settings on the custom Wizard Page, puts this function in the script, and CALLS setpreviousdata (previousdatakey,...) to replace it with one at a time.
Function checkserial (Serial: string): Boolean;
This function automatically displays a serial number object on the user information Wizard Page (provided that userinfopage = yes is used in the [setup] section ). If true is returned, the serial number is accepted. If false is returned, the serial number is rejected. Note: When serial numbers are used, the software is not encrypted, and the Inno Setup source code is obtained for free. It is not difficult for experienced people to delete serial number protection from the installer. This function allows you to carefully check the Input Serial Number (stored in the {userinfoserial} constant) in your application ). The test code is as follows:
Function checkserial (Serial: string): Boolean; Begin If serial = 'abcdef-1234567890 'then Result: = true; End; |
A page will appear during the installation process, as shown below:
If the serial number is incorrect, the next button will be invalid. Only the correct serial number can make the next button valid. note again: Do not expect this method to protect your software.
Function getcustomsetupexitcode: integer;
Return a non-zero value. The command installer returns a custom exit code. This function is called only when the installation is complete and the exit code is zero. The common exit code is as follows:
Code |
Description |
0 |
The installation is successful. |
1 |
An error occurred while initializing the installer. |
2 |
Click Cancel before the actual installation, or click "This will install..." at the beginning ......" Select No |
3 |
A fatal error occurs when you are preparing for the next installation phase. This error occurs only in extreme cases, such as memory depletion. |
4 |
Fatal errors occurred during actual installation |
5 |
In the actual installation process, click Cancel or in the "terminate-retry-Ignore" dialog box, click terminate. |
6 |
The installer is forcibly terminated by the debugger. |
7 |
No installation is available during installation preparation. |
8 |
The installation fails during the preparation and installation phase, and the system needs to be restarted to solve the problem. |
For example, when you use Inno Setup to debug the compiled Installation File and press Ctrl + F2, the following debugging output will prompt you as follows:
Exit Code 6. The installer is forcibly terminated by the debugger.
Function preparetoinstall (VAR needsrestart: Boolean): string;
During the installation phase, a non-empty string command is returned to stop the installer. This string will be used as an error message. Setting needsrestart to true requires you to restart the system, this function is called only when the installer finds that it cannot continue.