ListGetFirstString Example

InstallShield 2014 ยป 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 ListGetFirstString and ListGetNextString

* functions.

*

* This script starts by creating a string list and adding

* program folder names to it.  ListGetFirstString is called

* then to get the first string from the list.  This call also

* makes the first string the current element.  A loop process

* follows to display the string retrieved from the list and

* then call ListGetNextString to get the next string.  The

* loop executes until ListGetFirstString or ListGetNextString

* reaches the end of the list.

*

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

 

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

#include "Ifx.h"

 

export prototype ExFn_ListGetFirstString(HWND);

 

function ExFn_ListGetFirstString(hMSI)

    STRING svString;

    LIST listID;

    NUMBER nResult;

begin

 

    // Create a 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;

 

    // Get the names of the program folders into a list.

    if GetGroupNameList(listID) < 0 then ;

      // Report ListCreate failure.

        MessageBox ("Unable to retrieve program folder names.", SEVERE);

    else

        // Get the first string in the list.

        nResult = ListGetFirstString (listID, svString);

 

        // Loop while list items continue to be retrieved.

        while (nResult != END_OF_LIST)

            // Display the current element.

            MessageBox (svString, INFORMATION);

 

            // Get the next string in the list.

            nResult = ListGetNextString (listID, svString);

        endwhile;

    endif;

 

    // Remove the list from memory.

    ListDestroy (listID);

 

end;