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

*

* This script first creates a list of strings and then displays

* the current string in a dialog.  Next, ListDeleteString

* is called twice, deleting the last two strings in the list.

* The current string is then displayed again.

*

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

 

#define TITLE_TEXT "ListDeleteString & ListCurrentString"

 

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

#include "Ifx.h"

 

export prototype ExFn_ListDeleteString(HWND);

 

function ExFn_ListDeleteString(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);

 

   // Display the current string in the list.

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

      MessageBox ("First call to ListCurrentString failed.", SEVERE);

   else

 

      szMsg   = "Current string in list: %s";

      SprintfBox (INFORMATION, TITLE_TEXT, szMsg, svString);

 

   endif;

 

   // Remove the current string ("Value three").

    if (ListDeleteString (listID) < 0) then

      MessageBox ("First call to ListDeleteString failed.", SEVERE);

   endif;

 

   // Remove the current string ("Value two").

   if (ListDeleteString (listID) < 0) then

      MessageBox ("Second call to ListDeleteString failed.", SEVERE);

   endif;

 

   // Display the current string in the list.

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

      MessageBox ("Second call to ListCurrentString failed.", SEVERE);

 

   else

      szMsg   = "Current string in list: %s";

      SprintfBox (INFORMATION, TITLE_TEXT, szMsg, svString);

 

   endif;

 

   // Remove the list from memory.

   ListDestroy (listID);

 

end;