Inno Setup entry (13) -- Pascal script (2)

Source: Internet
Author: User

Event functions (2)

Function checkpassword (password: string): Boolean;

If you installProgramInPascalThis function is found in the script. It automatically displays the password page and callsCheckpasswordCheck the password. ReturnTruePassword accepted.FalseReject. TestCodeAs 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[Code]Store the real password in the section. It is best to use other information for comparison, for exampleGetmd5ofstring (password)Calculate the actual passwordMD5Value to protect the actual password.

Function needrestart (): Boolean;

IfTrueThe installer prompts the user to restart the system at the end of installation,FalseNo. The test code is as follows:

 

Function needrestart (): Boolean;

Begin

Result: = true;

End;

 

After the installation is completeFinishPage, the following options will appear:

Function updatereadymemo (space, newline, memouserinfoinfo, memodirinfo, memotypeinfo, memocomponentsinfo, memogroupinfo, memotasksinfo: string): string;

If the function exists in the script Ready to install This function is automatically called when the page is changed to an activity page. This function returns a piece of text, which is displayed on Ready to install The setting remarks on the page, and the text will be used Newline The parameter is split into a separate multi-line string. Space Refers to space. The test is six, Other parameters will contain characters that the installer uses to set segments ( It may be empty. ) . For example Memodirinfo The 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, adds the function to the script, and callsSetpreviusdata (previusdatakey ,...)Replace it and set one at a time.

Function checkserial (Serial: string): Boolean;

This function automatically displays a serial number object on the user information Wizard Page. ( Premise: [Setup] Section Userinfopage = yes) . Return True Indicates accepting the serial number. False Reject. Note: When serial numbers are used, the software is not encrypted and Inno Setup Source codeIt is free of charge. It is not very difficult for experienced people to delete serial number protection from the installer. This function allows you to check the Input Serial number in your application. ( Stored in {Userinfoserial} Constant ) . 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:

IfSerial numberIncorrect,NextThe button will be invalid. Only the correct serial number can makeNextButton is valid. note again: Do not expect this method to protect your software.

Function getcustomsetupexitcode: integer;

Returns a non-zero value. The command installer returns a custom exit code.This function is called only when the installation is completed 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

Click Cancel during the actual installation or terminate-Retry-In the 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 exampleInno SetupWhen debugging the compiled Installation File, pressCTRL + F2The following debugging output will prompt the following:

Exit code:6The installer is forcibly terminated by the debugger.

Function preparetoinstall (VAR needsrestart: Boolean): string;

In the installation phase, a non-empty string command is returned to stop the installation program. This string will be used as an error message and setNeedsrestartIsTrueThe user is required to restart the system. This function is called only when the installation program finds that it cannot continue.

 

From: http://www.360doc.com/content/13/0327/14/4221543_274246727.shtml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.