InstallShield 2019 » InstallScript Language Reference
Note • To call this function in a Basic MSI setup, you must first create a custom action for the entry-point function, execute the custom action in a sequence or as the result of a dialog's control event, and then build the release.
/*-----------------------------------------------------------*\
*
* InstallShield Example Script
*
* Demonstrates the ConfigAdd function.
*
* This example script adds two statements to a configuration
* file. First, it calls ConfigFileLoad to load the file for
* editing. Next, it adds a DEVICE statement. Then it adds a
* DEVICEHIGH statement. Finally, it backs up the original file
* and saves the edited file.
*
* Note: Before running this script, create a configuration
* file named ISExampl.sys in the root of drive C.
* That file should include the following lines:
*
* DEVICE=C:\Exapp\Exapp.sys
* DEVICE=C:\Otherapp.exe
*
\*-----------------------------------------------------------*/
#define EXAMPLE_SYS "C:\\ISExampl.sys"
#define EXAMSYS_BAK "ISExampl.bak"
// Variables to pass as parameters to ConfigAdd.
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_ConfigAdd(HWND);
function ExFn_ConfigAdd(hMSI)
STRING szKey, szValue, szRefKey;
begin
// Load the target config file into memory.
if ConfigFileLoad (EXAMPLE_SYS) < 0 then
MessageBox ("Unable to load " + EXAMPLE_SYS + ".", SEVERE);
abort;
endif;
// Set up parameters for the first call to ConfigAdd.
szKey = "DEVICE";
szValue = "C:\\Exapp\\Exapp2.sys";
szRefKey = "Exapp.sys";
// Add the line DEVICE=C:\Exapp\Exapp2.SYS before the first
// statement that references Exapp.sys.
if (ConfigAdd (szKey, szValue, szRefKey, BEFORE) < 0) then
MessageBox ("First call to ConfigAdd failed.", WARNING);
abort;
endif;
// Set up parameters for the second call to ConfigAdd.
szKey = "DEVICEHIGH";
szValue = "C:\\Otherapp\\Otherapp.exe";
szRefKey = "Otherapp.exe";
// Replace the last existing line that references OtherApp.exe
// with the statement DEVICEHIGH=C:\Otherapp\Otherapp.exe.
if (ConfigAdd (szKey, szValue, szRefKey, REPLACE) < 0) then
MessageBox ("Second call to ConfigAdd failed.", WARNING);
abort;
endif;
// Backup the original file and save the edited file.
if ConfigFileSave (EXAMSYS_BAK) < 0 then
MessageBox ("Unable to save " + EXAMPLE_SYS + ".", SEVERE);
else
MessageBox (EXAMPLE_SYS + " was updated and saved.",INFORMATION);
endif;
end;
InstallShield 2019 Help LibraryApril 2019 |
Copyright Information | Flexera |