EzConfigAddDriver Example

InstallShield 2015 ยป 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 EzConfigAddDriver function.

*

* This example calls EzConfigAddDriver to add four statements

* to a configuration file.

*

* -- The first call to EzConfigAddDriver adds a new line of

*    text after the last line.

*

* -- The second call adds a new line of text before the first

*    line.

*

* -- The third call adds the driver C:\DRDOS\HIDOS.SYS after

*    the key HIMEM.SYS

*

* -- The fourth call adds the driver EXAPP.SYS before the key

*    HIMEM.SYS.

*

* Note: Before running this script, create a configuration file

*       named ISExampl.sys in the root of drive C.  For best

*       effect, include the following line in that file:

*

*       DEVICE=C:\\Himem.sys

*

\*--------------------------------------------------------------*/

 

#define EXAMPLE_SYS "C:\\ISEXampl.sys"

 

// Include Ifx.h for built-in InstallScript function prototypes.

#include "Ifx.h"

 

export prototype ExFn_EzConfigAddDriver(HWND);

 

function ExFn_EzConfigAddDriver(hMSI)

    STRING szDriver, szRefKey;

begin

 

    // Set the default configuration file.

    ConfigSetFileName (EXAMPLE_SYS);

 

    // Set up parameters for next call to EzConfigAddDriver.

    szDriver  = "C:\\NEW\\MYAPP.DRV";

    szRefKey  = "";

 

    // Add a driver to the end of the configuration file.

    if (EzConfigAddDriver (szDriver, szRefKey, AFTER) < 0) then

        MessageBox ("First call to EzConfigAddDriver failed.", SEVERE);

    else

        MessageBox ("First call to EzConfigAddDriver successful.", INFORMATION);

    endif;

 

    // Set up parameters for next call to EzConfigAddDriver.

    szDriver  = "C:\\SYSTEM\\DMDRVR.BIN";

    szRefKey  = "";

 

    // Add a driver to the top of the configuration file.

    if (EzConfigAddDriver (szDriver, szRefKey, BEFORE) < 0) then

        MessageBox ("Second call to EzConfigAddDriver failed.", SEVERE);

    else

        MessageBox ("Second call to EzConfigAddDriver successful.", INFORMATION);

    endif;

 

    // Set up parameters for next call to EzConfigAddDriver.

    szDriver  = "C:\\DRDOS\\HIDOS.SYS";

    szRefKey  = "HIMEM.SYS";

 

    // Add the "HIDOS.SYS" driver after the "HIMEM.SYS" key.

    if (EzConfigAddDriver (szDriver, szRefKey, AFTER) < 0) then

        MessageBox ("Third call to EzConfigAddDriver failed.", SEVERE);

    else

        MessageBox ("Third call to EzConfigAddDriver successful.", INFORMATION);

    endif;

 

    // Set up parameters for next call to EzConfigAddDriver.

    szDriver  = "EXAPP.SYS";

    szRefKey  = "HIMEM.SYS";

 

    // Add the "EXAPP.SYS" driver before the "HIMEM.SYS" key.

    if (EzConfigAddDriver (szDriver, szRefKey, BEFORE) < 0) then

        MessageBox ("Fourth call to EzConfigAddDriver failed.", SEVERE);

    else

        MessageBox ("Fourth call to EzConfigAddDriver successful.", INFORMATION);

    endif;

 

end;