ListAddString Example

InstallShield 2016 » 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 ListAddString function.

*

* ListAddString is called to add a string to the string list.

* Then it is called again to add another string after the

* first.  This string is also set as the current element.

* ListAddString is called for the third time to add a string

* before the current element.

*

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

 

#define  TITLE_TEXT "ListAddString Example"

#define  MSG_TEXT   "Hardware devices:"

 

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

#include "Ifx.h"

 

export prototype ExFn_ListAddString(HWND);

 

function ExFn_ListAddString(hMSI)

   STRING szString, svString;

    LIST   listID;

begin

 

    // Create an empty string list.

    listID = ListCreate (STRINGLIST);

 

    // If an error occurred, report it; then terminate.

    if (listID = LIST_NULL) then

        MessageBox ("Unable to create list.", SEVERE);

        abort;

    endif;

 

    // Add a string to the list. This string becomes the current element.

    szString = "Keyboard";

    if (ListAddString (listID, szString, AFTER) < 0) then

        MessageBox ("ListAddString failed.", INFORMATION);

    endif;

 

    // Add a second string; insert it after the current element.

    // This string then becomes the current element.

    szString = "Mouse";

    if (ListAddString (listID, szString, AFTER) < 0) then

        MessageBox ("ListAddString failed.", INFORMATION);

    endif;

 

    // Add a third string; insert it before the current element.

    szString = "Monitor";

    

    if (ListAddString (listID, szString, BEFORE) < 0) then

        MessageBox ("ListAddString failed.", INFORMATION);

    endif;

 

    // Show the list of strings.

    SdShowInfoList (TITLE_TEXT, MSG_TEXT, listID);

 

    // Retrieve and display the current element.

    ListCurrentString (listID, svString);

    

    MessageBox (svString, INFORMATION);

 

    // Remove the list from memory.

    ListDestroy (listID);

 

end;