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

*

* In this script, two strings are added to an empty list.

* The list is then displayed in a dialog. Next,

* ListSetCurrentString is called to replace the current

* element. The list is then displayed again in a

* dialog.

*

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

 

#define  TITLE_TEXT "ListSetCurrentString Example"

#define  MSG_TEXT   "Elements in listID:"

 

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

#include "Ifx.h"

 

export prototype ExFn_ListSetCurrentString(HWND);

 

function ExFn_ListSetCurrentString(hMSI)

    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 two strings to the list.

    ListAddString (listID, "Keyboard", AFTER);

    ListAddString (listID, "Monitor", AFTER);

 

    // Disable the Back button in setup dialogs.

    Disable (BACKBUTTON);

 

    // Display the list.

    SdShowInfoList (TITLE_TEXT, MSG_TEXT, listID);

 

    // Replace the value of the second item with a new value.

    if (ListSetCurrentString(listID, "Mouse") < 0) then

        MessageBox ("ListSetCurrentString failed.", SEVERE);

    endif;

 

    // Display the new altered list.

    SdShowInfoList (TITLE_TEXT, MSG_TEXT, listID);

 

    // Remove the list from memory.

    ListDestroy (listID);

 

end;