PathAdd Example

InstallShield 2019 ยป InstallScript Language Reference

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

*

* This example script shows how to add paths to a search path

* in the path buffer.  It begins by initializing the path buffer

* with a search path. Then, it adds a new path to the front of

* the search path.  Next, it gets the modified search path from

* the search buffer and displays it.

*

* It then initializes the path buffer with the modified search

* path and adds a new path before the last path in the path

* buffer.  Finally, it gets the modified search path from the

* search buffer and displays it.

*

* Note: PathGet is called after the first PathAdd statement

*       only so the value of the path buffer can be displayed

*       for demonstration purposes.  In a production script,

*       you would finish building the search path in the buffer

*       before calling PathGet.

*

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

 

#define TITLE "Path buffer example"

 

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

#include "Ifx.h"

 

export prototype ExFn_PathAdd(HWND);

 

function ExFn_PathAdd(hMSI)

    STRING svSearchPath;

begin

 

    // Set up the search path to pass as a parameter to PathSet.

    svSearchPath = "C:\\DOS;C:\\Windows;C:\\Temp";

 

    // Initialize the path buffer.

    PathSet (svSearchPath);

 

    // Display the initial search path.

    SprintfBox (INFORMATION,TITLE,

               "The starting search path is %s.",svSearchPath);

 

    // Add C:\MSOffice as the first path in the search path.

    if (PathAdd("C:\\MSOffice", "", FULL, BEFORE) < 0) then

        MessageBox ("Unable to add C:\\MsOffice to path buffer.", SEVERE);

        abort;

    endif;

 

    // Get the search path from the path buffer; this call also releases

    // the memory allocated for the path buffer.

    PathGet (svSearchPath);

 

    // Display the search path.

    // svSearchPath will contain C:\MSOffice;C:\DOS;C:\Windows;C:\Temp.

    SprintfBox (INFORMATION,TITLE,

               "C:\\MSOffice added before first path.\n\nThe search path is %s.",

               svSearchPath);

 

    // Initialize path buffer to hold the search path.

    PathSet (svSearchPath);

 

    // Add C:\APP2 before C:\Temp in the path buffer.

    if (PathAdd ("C:\\APP2", "Temp", PARTIAL, BEFORE) < 0) then

        MessageBox ("Unable to add C:\\APP2 to path buffer.", SEVERE);

        abort;

    endif;

 

    // Get the search path from the path buffer; this call also releases

    // the memory allocated for the path buffer.

    PathGet (svSearchPath);

 

    // Display the modified search path.

    // svSearchPath will contain C:\MSOffice;C:\DOS;C:\Windows;C:\App2;C:\Temp.

    SprintfBox (INFORMATION,TITLE,

               "C:\\APP2 added before C:\\Temp.\n\nThe search path is %s.",

               svSearchPath);

 

end;