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

*

* This example script shows how to delete paths from the path

* buffer.  It begins by initializing the path buffer with a

* search path.  Then, it deletes any path that includes a

* reference to "Temp".  Next, it gets the modified search path

* from the search buffer and displays it.

*

* It then initializes the path buffer with the modfied search

* path and deletes a specific path.  Finally, it gets the

* search path from the search buffer and displays it.

*

* Note: PathGet is called after the first PathDelete 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_PathDelete(HWND);

 

function ExFn_PathDelete(hMSI)

    STRING svSearchPath;

begin

 

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

    svSearchPath = "C:\\DOS;C:\\WINDOWS;C:\\TEMP;" +

                   "C:\\EXAMPLE\\SOURCE;D:\\WORK\\TEMP";

 

    // Initialize the path buffer.

    PathSet (svSearchPath);

 

    // Display the initial search path.

    SprintfBox (INFORMATION,TITLE,

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

 

    // Delete C:\Temp from the path buffer.

    if (PathDelete ("TEMP", PARTIAL) < 0) then

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

    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:\DOS;C:\WINDOWS;C:\EXAMPLE\SOURCE.

    SprintfBox (INFORMATION, TITLE,

               "All paths referencing 'Temp' were deleted.\n\nThe search path is %s.",

               svSearchPath);

 

    // Set up the path buffer again.

    PathSet (svSearchPath);

 

    // Delete C:\\EXAMPLE\\SOURCE from the path buffer.

    if (PathDelete ("C:\\EXAMPLE\\SOURCE", FULL) < 0) then

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

    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:\DOS;C:\WINDOWS.

    SprintfBox (INFORMATION, TITLE,

               "C:\\EXAMPLE\\SOURCE was deleted.\n\nPath is %s.",

               svSearchPath);

 

end;