FindAllDirs Example

InstallShield 2019 » 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

*

* This example demonstrates the FindAllDirs function.

*

* FindAllDirs is called to retrieve all directories located

* in a specified directory.  Subdirectories are included at

* the user's discretion.

*

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

 

#define TITLE "FindAllDirs Example"

 

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

#include "Ifx.h"

 

export prototype ExFn_FindAllDirs(HWND);

 

function ExFn_FindAllDirs(hMSI)

    LIST   listDirs;

    STRING svSearchPath, szMsg;

    NUMBER nOp, nResult;

begin

 

    // Disable the Back button in setup dialogs.

    Disable (BACKBUTTON);

 

    // Ask the user for a path.

    AskPath ("Enter an existing path.", "", svSearchPath);

 

    // Ask whether or not to include subdirectories.

    if (AskYesNo ("Include subdirectories?", YES) = YES) then

        nOp    = INCLUDE_SUBDIR;

        szMsg = "Directories and Subdirectories";

    else

        nOp    = EXCLUDE_SUBDIR;

        szMsg = "Directories only";

    endif;

 

    // Display a message while building the list.

    SdShowMsg ("Searching . . . please wait.", TRUE);

 

    // Create a STRING list for directory names.

    listDirs = ListCreate (STRINGLIST);

 

    // Find requested elements place them into the list.

    nResult = FindAllDirs (svSearchPath, nOp, listDirs);

 

    // Close the message box.

    SdShowMsg ("", FALSE);

 

    if ( nResult< 0) then

        // Report no matches.

        SprintfBox (INFORMATION, TITLE, "No directories in %s",

                   svSearchPath);

    else

        // Display the list.

        SdShowInfoList (TITLE, szMsg, listDirs);

    endif;

 

end;