LongPathFromShortPath Example

InstallShield 2016 » 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 functions LongPathToShortPath and

* LongPathFromShortPath.


* First, LongPathToShortPath is called to convert a long path

* to a short path.  Then LongPathFromShortPath is called to

* convert the short path to a long path.  The result of each

* is displayed in a message box.




#define LONG_PATH "C:\\Program files"

#define TITLE "LongPathToShortPath & LongPathFromShortPath"


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

#include "Ifx.h"


export prototype ExFn_LongPathFromShortPath(HWND);


function ExFn_LongPathFromShortPath(hMSI)

    STRING svPath, szTitle, szMsg;



    // Prompt user to enter a long path.

    szMsg    = "Please select an existing long path:";

    AskPath (szMsg, LONG_PATH, svPath);


    // Display the long path.

    szMsg = "The long path is shown below: \n\n%s";

    SprintfBox (INFORMATION, TITLE, szMsg, svPath);


    //Convert the long path to a short path.

    if (LongPathToShortPath (svPath) < 0) then;

        MessageBox ("LongPathToShortPath failed.", SEVERE);



        // Display the short path.

        szMsg = "The short path is shown below: \n\n%s";

        SprintfBox (INFORMATION, TITLE, szMsg, svPath);



    // Restore the long path from the short path.

    if (LongPathFromShortPath (svPath) < 0) then

        MessageBox ("LongPathFromShortPath failed.", SEVERE);


        // Display the restored long path.

        szMsg = "The restored long path is shown below: \n\n%s";

        SprintfBox (INFORMATION, TITLE, szMsg, svPath);