PathFind 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 PathSet, PathFind, and PathGet functions.

*

* First, PathSet is called to place a search path into the path

* buffer.  Then PathFind is then called to search the path

* buffer for instances of a specific path.  Finally, PathGet

* is called to return the contents of the path buffer.

*

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

 

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

#include "Ifx.h"

 

export prototype ExFn_PathFind(HWND);

 

function ExFn_PathFind(hMSI)

    STRING szString, szMsg, svResult, svString, szDir;

    NUMBER nResult;

    BOOL   bDir, bSearch;

begin

 

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

    szString = "C:\\DOS;C:\\USERS\\BIN;C:\\MSC\\BIN;";

 

    // Place the search path into the path buffer

    if (PathSet (szString) < 0) then

        // Report an error; then terminate.

        MessageBox ("PathSet failed.", SEVERE);

        abort;

    else

        szMsg = "PathSet set the path buffer to: %s";

        SprintfBox (INFORMATION, "PathSet Example", szMsg, szString);

    endif;

 

    // Set PathFind variables.

    szDir = "BIN";

 

    // Search the path buffer for paths that include a folder named "BIN".

    nResult = PathFind(szDir, svResult, PARTIAL, RESTART);

 

    // Error check PathFind.

    if (nResult < 0) then

        MessageBox("PathFind failed.", SEVERE);

        abort;

    endif;

 

    // Loop through the string to find all occurrences of the szDir string.

 

    while (nResult = 0)

        SprintfBox(INFORMATION, "PathFind example",

                  "Search for %s.\n\nFound:  %s", szDir, svResult);

        nResult = PathFind(szDir, svResult, PARTIAL, CONTINUE);

    endwhile;

 

    // Get the contents of the path buffer.

    if (PathGet (svString) < 0) then

        MessageBox ("PathGet failed.", SEVERE);

    else

        // Display the path string.

        SprintfBox (INFORMATION, "Path Get Example", "Path is: %s", svString);

    endif;

 

end;