InstallShield 2016 » InstallScript Language Reference
Project • This information applies to the following project types:
• | InstallScript |
• | InstallScript MSI |
/*--------------------------------------------------------------*\
*
* InstallShield Example Script
*
* Demonstrates the SetupType function.
*
* Comments: To run this example script, create a project (or
* insert into a project) with several features and
* subfeatures with components containing files.
* This example includes setup of uninstallation
* functionality.
*
\*--------------------------------------------------------------*/
// Specify your feature name here. These are the names you gave to your
// features in the IDE. A NULL ("") string specifies base features.
#define ASKDESTTITLE "Choose Destination Location"
#define ASKDESTMSG "Choose a destination location for the application."
#define SETUPTYPETITLE "Choose Setup Type"
#define SETUPTYPEMSG "Select a setup type."
#define FEATURE ""
#define SDFEATDLGTITLE "Feature Selection"
#define SDFEATDLGMSG "Select features to install and destination location."
#define APPBASE_PATH "Your Company\\Word Processor"
#define COMPANY_NAME "Your Company"
#define PRODUCT_NAME "Word Processor"
#define PRODUCT_VERSION "1.0"
#define PRODUCT_KEY "Word Processor"
#define DEINSTALL_KEY "Word Processor"
#define UNINSTALL_NAME "Word Processor"
prototype HandleFeatureError (NUMBER);
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_SetupType(HWND);
function ExFn_SetupType(hMSI)
STRING svLogFile;
NUMBER nvDisk, nResult;
begin
// Disable the Back button in setup dialogs.
Disable (BACKBUTTON);
// Get the destination location.
INSTALLDIR = PROGRAMFILES ^ APPBASE_PATH;
AskDestPath (ASKDESTTITLE, ASKDESTMSG, INSTALLDIR , 0);
// Get setup type and target location with SdSetupType.
INSTALLDIR = PROGRAMFILES ^ APPBASE_PATH;
nResult = SetupType (SETUPTYPETITLE, SETUPTYPEMSG, "", TYPICAL, 0);
// If Custom setup type is selected, let user select features
// and change location if desired.
if (nResult = CUSTOM) then
SdFeatureDialogAdv (SDFEATDLGTITLE, SDFEATDLGMSG,
INSTALLDIR, FEATURE);
endif;
// Set up uninstallation.
InstallationInfo (COMPANY_NAME, PRODUCT_NAME,
PRODUCT_VERSION, PRODUCT_KEY);
svLogFile = "Uninst.isu";
DeinstallStart (INSTALLDIR, svLogFile, DEINSTALL_KEY, 0);
RegDBSetItem (REGDB_UNINSTALL_NAME, UNINSTALL_NAME);
// Transfer files based on feature selection. Handle errors.
Enable (STATUSDLG);
Enable (INDVFILESTATUS);
StatusUpdate (ON, 100);
nResult = FeatureMoveData (MEDIA, nvDisk, 0);
HandleFeatureError (nResult);
Disable (INDVFILESTATUS);
Disable (STATUSDLG);
end;
/*--------------------------------------------------------------------------*\
*
* Function: HandleFeatureError
*
* Purpose: This function evaluates the value returned by a feature
* function and if the value is less than zero, displays the error
* number and aborts the setup.
*
\*--------------------------------------------------------------------------*/
function HandleFeatureError (nResult)
NUMBER nvError;
STRING svFeatureSource, svFeature, svComponent, svFile;
begin
if (nResult < 0) then
ComponentError (svFeatureSource, svFeature, svComponent, svFile, nvError);
SprintfBox (INFORMATION, "Data Transfer Error Information",
"FeatureError returned the " +
"following data transfer error.\n" +
"Setup will now abort.\n\n" +
"Media Name: %s\nFeature: %s\nComponent: %s\n" +
"File: %s\nError Number: %ld",
svFeatureSource, svFeature, svComponent, svFile, nvError);
abort;
endif;
end;
InstallShield 2016 Help LibraryMay 2017 |
Copyright Information | Flexera Software |