InstallShield study Note 3: script (1)

Source: Internet
Author: User
1. Engineering description

In practical applications, the installsrcipmsi and installsrcipare the two most common projects. Basically, scripts can be shared,

But there is a difference:

In installsrcipmsi, the installation paths can be installdir and targetdir,

However, only targetdir can be used in installsrcept.

Here, installsrcipt describes the problems encountered during use.

 

2. Select license

In onfirstuibefore, the license file license page has been customized for the project. The script code is as follows ::

Dlg_SdLicense2:    szTitle = "";    szOpt1 = "";    szOpt2 = "";    //{{IS_SCRIPT_TAG(License_File_Path)    szLicenseFile = SUPPORTDIR ^ "License.rtf";    //}}IS_SCRIPT_TAG(License_File_Path)    //{{IS_SCRIPT_TAG(Dlg_SdLicense2)    nResult = SdLicense2Ex( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted, TRUE );    //}}IS_SCRIPT_TAG(Dlg_SdLicense2)    if (nResult = BACK) then        goto Dlg_SdWelcome;    else        bLicenseAccepted = TRUE;    endif;

Sdlicense2ex (sztitle, szopt1, szopt2, szlicensefile, blicenseaccepted, true) is used here ),

In actual application, the license file is in TXT format. When setting parameters, you must set the last parameter to flalse. Otherwise, the license file may not be displayed.

Therefore, sdlicense2ex (sztitle, szopt1, szopt2, szlicensefile, blicenseaccepted, false) is used. (For details about the meaning of each parameter, refer to the help documentation)

 

3. Select the installation path

By default, the installation path is after the installation mode is selected.

If "all" is selected, it will be installed in the default path, that is, under c: \ Program Files \ xxx

If you select "Custom", the installation path is prompted.

If you see a poor experience, you can select the path in advance. The specific script code is as follows:

Dlg_SdAskDestPath2:    szTitle = "";    szMsg = "";
//{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2)        nResult = SdAskDestPath2( szTitle, szMsg, szDir );    //}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)    TARGETDIR = szDir;
If (nresult = back) goto dlg_sdregisteruser; // note that after you click "previous", you should jump back to the input user information page dlg_setuptype2: sztitle = ""; szmsg = ""; nresult = custom; // {is_script_tag (dlg_setuptype2) nresult = setuptype2 (sztitle, szmsg, "", nsetuptype, 0 ); //} is_script_tag (dlg_setuptype2) if (nresult = back) Then goto dlg_sdaskdestpath2; // select the installation mode and click "previous ", switch back to the installation path and select else nsetuptype = nresult; If (nsetuptype! = Custom) Then sztargetpath = targetdir; nsize = 0; featurecomparesizerequired (Media, sztargetpath, nsize); If (nsize! = 0) Then MessageBox (szsdstr_notenoughspace, warning); goto dlg_sqlserver; // choose Custom instead of custom. Click "Next" to go to the "Install Database" Page. endif; // The following is the add part. Select custom as the custom part. Click "Next". You need to go to the else goto dlg_sdfeaturetree; endif; dlg_sdfeaturetree page of the Selection Component page: if (nresult = back) & (nsetuptype! = Custom) goto dlg_sdaskdestpath2; sztitle = ""; szmsg = ""; szfeatures = ""; nlevel = 2; If (nsetuptype = custom) then // {is_script_tag (dlg_sdfeaturetree) nresult = sdfeaturetree (sztitle, szmsg, targetdir, szfeatures, nlevel); //} is_script_tag (identifier) if (nresult = back) goto dlg_setuptype2; endif;

Note: Pay attention to the Goto path during modification. If the configuration is not met, a page error occurs when you click "previous" or "Next.

 

4. Select the installation component

Note: installshiled has its own memory function. After selecting parameters, such as paths and components, on the current page, these parameters are not modified when "Next" is not clicked,

Click "previous". After "Next", the default value is displayed.

Requirement: When you select to install a component, when the component has been selected, click "previous" to view the previous data and return to the current page. Ensure that the current component is still in the selected status.

Idea: set a global variable in sdfeaturetree to mark the component selection status.

Use featureisitemselected (szfeaturesource, szfeature) to check whether the component is selected;

Use featureselectitem (szfeaturesource, szfeature, bselect); set the component Status

(1) Select "dailog source" in setup. rul and select sdfeaturetree to obtain the code of the selected component.

(2) define global variables

// ================================================ ================================================================== /// /File Name: setup. RUL // Description: blank setup main script file // comments: blank setup is an empty setup project. if you want to // create a new project. step-by step instructions use the // project assistant. /// =================================================== ===================================================/ /encoded ded header files ------------------------------------------------------ # include "ifx. H "// global variables bool bselectfeature1, bselectfeature2;

(3) set the status in sdfeaturetree (sztitle, szmsg, svdir, szcomponents, nlevel.

Added under case sd_tree_component: condition, because this event is triggered when we select a component.

Add two pieces of code

Bselectfeature1 = featureisitemselected (media, "defaultfeature \ newfeature1 ");

Bselectfeature2 = featureisitemselected (media, "defaultfeature \ newfeature2 ");

Note: "defaultfeature \ newfeature1" indicates the name of the new feature, not displayname.

Case sd_tree_component: ntncode = ctrlgetnotificationcode (szdlg); numtostr (STN, ntncode); If (ntncode =-402) Then // tvn_selchange if (dependencies (ncomponentview, strcomp) = 0) then componentgetdata (Media, strcomp, component_field_description, N, strdisplayname); setwindowtext (ctrlgetdlgitem ("", hwnddlg, plaintext), strdisplayname); endif; // set required size ISRT. _ componentgett Otalcostex (_ hcontext, media, svdir, strreqsize, nunitused); If (nunitused! = Kbytes) & (nunitused! = Mbytes) & (nunitused! = Gbytes) Then nunitused = Mbytes; endif; If (strlengthchars (strreqsize) = 0) Then strreqsize = "0.00"; endif; strreqsize = strreqsize + "" + strconvertsizeunit (nunitused); sprintf (strtempctrltxt, strreqformat, strreqsize, strdrive); setwindowtext (hwndreqctrl, strtempctrltxt ); // set available size if (strlength (svdir)> 0) Then ISRT. _ getdiskspaceexex (svdir, stravailsize, nunitused, true, true); If (strlengthchars (stravailsize) = 0) Then stravailsize = "0.00"; endif; stravailsize = stravailsize + "" + strconvertsizeunit (nunitused); sprintf (optional, stravailformat, stravailsize, strdrive); setwindowtext (hwndavailctrl, optional); endif; // set the selection status
Bselectfeature1 = featureisitemselected (media, "defaultfeature \ newfeature1"
);            bSelectFeature2 = FeatureIsItemSelected(MEDIA, "DefaultFeature\\NewFeature2");            bDone  = FALSE;

(4) Add the following configuration in dlg_sdfeaturetree:

Featureselectitem (media, "defaultfeature \ newfeature1", bselectfeature1 );

Featureselectitem (media, "defaultfeature \ newfeature2", bselectfeature2 );

Tip: notice that "defaultfeature \ newfeature1" and "defaultfeature \ newfeature2" are the same in step (3). You can define global values using # define, as shown in figure

# Define feature1 "defaultfeature \ newfeature1"
# Define feature2 "defaultfeature \ newfeature2"

Code:

Dlg_sdfeaturetree: If (nresult = back) & (nsetuptype! = Custom) goto dlg_sdaskdestpath2; sztitle = ""; szmsg = ""; szfeatures = ""; nlevel = 2; If (nsetuptype = custom) Then featureselectitem (media, "defaultfeature \ newfeature1", feature); featureselectitem (media, "defaultfeature \ newfeature2", feature); // or // featureselectitem (Media, feature1, feature ); // featureselectitem (Media, feature2, bselectfeature2); // {is_script_tag (dlg_sdfeaturetree) nresult = sdfeaturetree (sztitle, szmsg, targetdir, szfeatures, nlevel ); //} is_script_tag (dlg_sdfeaturetree) if (nresult = back) goto dlg_setuptype2; endif;

InstallShield study Note 3: script (1)

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.