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

*

* ListAddString retrieves the current string element from a

* string list.

*

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

 

#define TITLE_TEXT "ListCurrentString Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_ListCurrentString(HWND);

 

function ExFn_ListCurrentString(hMSI)

    STRING szString, svString, szMsg;

    LIST   listID;

begin

 

    // Create the 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 three strings to the list.

    ListAddString (listID, "First string", AFTER);

    ListAddString (listID, "Second string", AFTER);

    ListAddString (listID, "Third string", AFTER);

 

    // Get the current element in the string list.

    if (ListCurrentString (listID, svString) < 0) then

        MessageBox ("ListCurrentString failed.", SEVERE);

    else

        // Report the value of the current item.

        szMsg = "Current element in list: '%s'";

        SprintfBox (INFORMATION, TITLE_TEXT, szMsg, svString);

    endif;

 

end;