StrRemoveLastSlash Example

InstallShield 2020 ยป 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 StrRemoveLastSlash function.

*

* The AskPath dialog is displayed, prompting the user to

* specify a path.  StrRemoveLastSlash is then called to remove

* the trailing backslash from the path returned by AskPath.

*

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

 

#define  TITLE_TEXT "StrRemoveLastSlash Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_StrRemoveLastSlash(HWND);

 

function ExFn_StrRemoveLastSlash(hMSI)

    STRING szDefaultPath, svString, szMsg, szTitle;

begin

 

    // Get a path from the user.  AskPath returns the

    // path with a trailing backslash.

    AskPath ("Specify a path:", INSTALLDIR, svString);

 

    // Remove the last slash from the path.

    if (StrRemoveLastSlash (svString) < 0) then

        // Report an error.

        MessageBox ("StrRemoveLastSlash failed.", SEVERE);

    else

        // Display the folder name after the last backslash

        // has been removed.

        MessageBox ("Specified path: " + svString, INFORMATION);

    endif;

 

end;