ConfigFind Example

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 ConfigFind function.

*

* This example script searches a batch file and reports whether

* or not the file includes a BUFFERS command.  It then finds

* and diplays all commands that reference Abc44.sys.

*

* Note: Before running this script, create a configuration

*       file called ISExampl.sys and store it in the root

*       of drive C.  The configuration file should include

*       the following lines:

*

*       DEVICE=C:\Abc44.sys /e:300

*       DEVICE=C:\Abc44.sys /s:off

*       BUFFERS=50

*

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

 

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

 

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

#include "Ifx.h"

 

export prototype ExFn_ConfigFind(HWND);

 

function ExFn_ConfigFind(hMSI)

    STRING svResult;

    NUMBER nResult;

begin

 

    // Load EXAMPLE_SYS.

    if (ConfigFileLoad (EXAMPLE_SYS) < 0) then

        MessageBox ("Unable to load " + EXAMPLE_SYS + ".", SEVERE);

        abort;

    endif;

    

    // Check for a BUFFERS command. RESTART is passed in the

    // third parameter to begin searching at the top of the file.

    nResult = ConfigFind("BUFFERS", svResult, RESTART);

    

    if (nResult < 0) then

        MessageBox ("BUFFERS command not found.", WARNING);

    else

        MessageBox (svResult, INFORMATION);

    endif;

    

    // Find the first command that references Abc44.sys.

    nResult = ConfigFind ("Abc44.sys", svResult, COMMAND | RESTART);

    

    if nResult < 0 then

        MessageBox ("The file Abc44.sys is not referenced.", WARNING);

    else

 

        // Loop while matching statements are found.

        while nResult = 0

            // Display the matching statement.

            MessageBox (svResult, INFORMATION);

    

            // Find the next statement that references Abc44.sys.

            nResult = ConfigFind ("Abc44.sys", svResult, CONTINUE);

        endwhile;

    

        MessageBox ("No more matches on Abc44.sys.", WARNING);

 

    endif;

 

end;