InstallShield scripting language is similar to the C language, the use of InstallShield wizards or templates can generate a basic script framework, on this basis can be modified and added on their own will.
I. Basic grammatical rules
1. Variables
BOOL Boolean value is True (1) or False (0)
Char character type one-byte long (8bit) character
HWND window handle for holding window handle
int integer two-byte long
List List type point to InstallShield, with Listcreate and Listdestroy
LONG Extended Numeric type
LPSTR Extension Pointers
Number value holds a value of four bytes long, ranging from 2147483648 to +2147483647
POINTER pointer type
Short low-value
String literals are very similar to LPCTSTR in VCs
variables, like the standard C language, require prior fame before use. Variables are generally known in two places, one is the external main program, such variables are global variables, and the second is the variable reputation of each function, such variables are local variables.
2. Operators
General and C language of the same operator, here do not do a detailed, the following main introduction of the more special operators,
(1) +,-, *,/
The above four operators are the same as the meanings and usages of the C language.
(2) &&
and operation, same as in C language, example: X1 && x2
(3) | |
Or operation, as in C language, example: X1 | | X2
(4)!
Non-operational, same as in C language, example:!x1
(5) *
Pointer manipulation, similar to the C language *
(6) &, | , ^, ~, <<, >>
bitwise AND, bit or, bitwise XOR, bitwise reversed, left and right shifted, with the same meaning and usage as the C language.
(7).
The operator is used for structures that are used to get the structure of the child, with the Delphi. Usage is similar, for example:
typedef SETTINGSREC
Begin
BOOL Bswitchon;
STRING szmssg[255];
INT Nval;
End
Settingsrec settings;
Program
Settings.bswitchon = FALSE;
SETTINGS.SZMSSG = "Off";
Settings.nval = 0;
(8) =
It can be used as an assignment number and also as a equals character, for example:
str1 = "String";
If str1= "String" Then
endif
(9) &
Address characters, similar to the C language usage.
<, >, =, <=, >=,! =
means less than, greater than, equal to, less than or equal to, greater than or equal to, not equal to
(11) +, ^,%
The operation used for the string.
(a)
A struct pointer, similar to the usage in C language.
(13) @
Used to get the string defined in the resource window, for example:
Szreferencefile = svdir ^ @PRODUCT_KEY;
3. Functions
InstallShield's functions need to be well known before they are used, and the functions are passed in a very similar way to the C language, such as the following function's fame:
Prototype Handlemovedataerror (number);
The name of the function is Handlemovedataerror, passing a parameter of type number. This function is also basically called the same as in C language.
The standard format for the function body is:
function functionname (nresult)
Function Variable fame Area
Begin
Program Area
End
The usual function returns the number of a type.
4. Main program Structure
The main procedure starts with program, ends with Endprogram,
Two. Basic structure of framework procedures
The program starts as a declaration area for functions and variables
The framework program created by the wizard contains the following main functions:
Prototype ShowDialogs ();
Display the Setup Wizard dialog box
Prototype Movefiledata ();
Moving file data
Prototype Handlemovedataerror (number);
Mobile Data error Handling
Prototype Processbeforedatamove ();
Processing before moving the file data
Prototype Processafterdatamove ();
Processing after moving the file data
Prototype Setupregistry ();
Installation registration, where users can add some code, usually for the operation of the registry
Prototype Setupfolders ();
Install the build shortcut, where the user can usually join the code that generates the shortcut
Prototype Cleanupinstall ();
Purge temporary files after installation is complete
Prototype Setupinstall ();
The actual process of installation
Prototype Setupscreen ();
Set the screen display of the installation process (including background color, font, etc.)
Prototype checkrequirements ();
Check installation requirements (including hard disk space, operating system platform, etc.)
Prototype Dialogshowsdwelcome ();
Display the Welcome dialog box window
Prototype Dialogshowsdlicense ();
dialog box for displaying licensing information
Prototype Dialogshowsdregisteruserex ();
dialog box showing user installation registration
Prototype Dialogshowsdaskdestpath ();
Display the Installation Path selection dialog box
Prototype Dialogshowsdsetuptype ();
Display the Installation Type selection dialog box
Prototype DIALOGSHOWSDCOMPONENTDIALOG2 ();
dialog box for displaying components for user selection when the user chooses the "Custom" installation
Prototype Dialogshowsdselectfolder ();
dialog box to display shortcut folder selection
Prototype Dialogshowsdfinishreboot ();
Display the Install Complete Restart dialog box
Programming Examples:
1. How to display the currently installed file in the upper left corner of the progress bar
Add the following statement in function Setupscreen ()
Enable (Indvfilestatus);
2. How to change the window background color
The SetColor (BACKGROUND, * * * *) function can change the window background color, add it to the appropriate position, where the second variable can be the following value:
Bk_blue Bk_magenta Bk_pink Bk_yellow
Bk_green Bk_orange bk_red
Some of the above are gradient colors
Bk_solidblack Bk_solidmagenta bk_solidred
Bk_solidblue Bk_solidorange Bk_solidwhite
Bk_solidgreen Bk_solidpink Bk_solidyellow
The second parameter can also be described using RGB, such as SetColor (BACKGROUND, RGB (0,0,255))
3. How to set up shortcuts in the following versions of InstallShield5.0
In the InstallShield5.1 above version can be established in the Resource window, and in the previous version must be used to solve the problem, if there is now a file RegPad.exe (installation path for the user selected), to the program in the "Start", "program" Add a shortcut to the implementation of the following program:
function Setupfolders ()
Number Nresult;
STRING Svresult,szcommand;
STRING SzName;
Begin
SzName = "RegPad.exe";
Szcommand = TARGETDIR ^ szName;
Longpathtoquote (Szcommand, TRUE);
Addfoldericon (folder_programs ^ "Regpad1.0beta", "Regpad",
Szcommand, TARGETDIR, "", 0, "", REPLACE);
4. How to control user serial number
In the wizard-generated framework program, a string-type global variable svserial is defined, and the value is assigned to the user-entered serial number at the end of Sdregisteruserex (), and you can judge the variable.
5. How to control the restart of the computer
Just add the following statement
System (Sys_bootwin);
6. How to add a statement to Autoexec.bat or Config.sys
The following program adds a line to Autoexec.bat
Openfilemode (File_mode_append);
OpenFile (Nvfilehandle, "c:\\", "Autoexec.bat");
WriteLine (Nvfilehandle, "SET path=%path%; C:\\orawin95\\bin ");
7. How to allow the user to choose whether to open the Readme file at the end of installation
Assuming that the Readme.txt file has been copied to the destination path, the following program displays a check box and, if the user chooses, opens Readme.txt with Notepad.
function Dialogshowsdfinishreboot ()
Number Nresult, ndefoptions;
STRING SzTitle, SZMSG1, SZMSG2, SzOption1, Szoption2,szpathls;
Number BOPT1, BOpt2;
Begin
if (! Batch_install) Then
BOPT1 = TRUE;
BOpt2 = FALSE;
SZMSG1 = "";
SZMSG2 = "";
SzOption1 = "Read the Readme file";
SzOption2 = "";
Nresult = Sdfinish (SzTitle, SZMSG1, SZMSG2, SzOption1, SzOption2, BOPT1, BOPT2);
If bOpt1 = TRUE Then
CopyFile ("Readme.txt", "Readme.txt");
Launchapp (windir^ "Notepad.exe", targetdir^ "Readme.txt");
endif
return 0;
endif
..........
8. How to specify a default path
Modify the following code in function Setupinstall (), as the default directory changes to C:\JttMis, as shown in the following modified code
if (Bis32bitsetup) then
Svdir = windisk ^ "Jttmis";
Else
Svdir = windisk ^ "Jttmis"; Use short names
endif
TARGETDIR = Svdir;
The getprofstring () function is a system function that reads information from the INI file
The first parameter specifies the path of the file
The second parameter specifies a section name
The third parameter specifies a keyword name
The last parameter is used to return the value of the keyword specified earlier. Note: Yes back!
The replaceprofstring () function is a system function that modifies the value of keyword in the INI file
The first parameter specifies the path of the file
The second parameter specifies a section name
The third parameter specifies a keyword name
The fourth parameter specifies the original value of keyword
The fifth parameter specifies a new value for the keyword
The original value is replaced by the new value in the fifth parameter only if the first 4 conditions match exactly
Replaceprofstring (Db_dir + "My.ini", "mysqld", "Basedir", "/" "+ Db_dir +"/"", "/" "+ replacestr (db_dir) +"/"");
Replaceprofstring (Db_dir + "My.ini", "mysqld", "DataDir", "/" "+ Db_dir +" data/"", "/" "+ replacestr (db_dir +" Data ") + "/"");
Perform batch processing
InstallShield Scripting language Learning Notes