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

*

* This script gets a fully qualified directory name from the

* user.  Next, it calls GetDir to return the selected directory

* name without the drive designation.  The resulting path is

* then displayed.

*

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

 

#define TITLE_TEXT "GetDir example"

 

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

#include "Ifx.h"

 

export prototype ExFn_GetDir(HWND);

 

function ExFn_GetDir(hMSI)

    STRING szMsg, svSelectedDir, svDirNameOnly;

begin

 

    // Get a fully qualified directory name from the user.

    AskPath ("Select a directory.", INSTALLDIR, svSelectedDir);

 

    // Get the directory name minus the drive designation.

    if (GetDir (svSelectedDir, svDirNameOnly) < 0) then

        // Report the error.

        MessageBox ("GetDir failed.", SEVERE);

    else

        // Display the directory name as it was returned by GetDir.

        SprintfBox (INFORMATION, TITLE_TEXT,

                   "Selected directory without drive designation: %s",

                   svDirNameOnly);

    endif;

 

end;