SelectDir

InstallShield 2014 » InstallScript Language Reference

Project: This information applies to the following project types:

InstallScript
InstallScript MSI

The SelectDir function has been superseded by the SelectDirEx function. You should use the SelectDirEx function when writing new installation programs. You can call the SelectDirEx function with nFlags set to BIF_RETURNONLYFSDIRS | BIF_EDITBOX to achieve the same result as calling the SelectDir function with bCreate set to FALSE.

The SelectDir function displays a dialog that allows the end user to specify the folder into which the application will be installed. The end user can enter a fully qualified folder name or select an existing folder from a list. If the end user enters an invalid folder name or an unqualified folder name, a message box is displayed to prompt the end user to enter a valid name. The fully qualified name of the selected folder is returned in svDir.

If the specified folder does not exist and the parameter bCreate is TRUE, SelectDir automatically creates the specified folder. If the parameter bCreate is set to FALSE and a non-existent folder is selected, the end user is not informed, and SelectDir does not create it. In this case, it is up to you to handle the selection contained in svDir.

Note: SelectDir is called automatically when the end user clicks the Browse button in the dialogs presented by AskDestPath, SdAskDestPath, and other InstallScript functions that obtain a folder name.

Syntax

SelectDir ( szTitle, szMsg, svDir, bCreate );

Parameters

SelectDir Parameters

Parameter

Description

szTitle

Specifies the title of this dialog. To display the default title ("Choose Folder"), pass a null string ("") in this parameter.

szMsg

Specifies the message you want to display in this dialog. To display the default instructions for this dialog, pass a null string ("") in this parameter.

svDir

Specifies the name of a folder that will appear as the default selection. Returns the fully qualified name of the folder selected by the end user.

bCreate

Specifies whether or not you want InstallShield to create the specified folder if it does not already exist. Pass one of the following predefined constants in this parameter:

TRUE—Indicates that the folder should be created if it does not exist.
FALSE—Indicates that the folder should not be created if it does not exist.

Return Values

If bCreate is FALSE, this function returns one of the following values:

SelectDir Return Values when bCreate is FALSE

Return Value

Description

IDOK (1)

Indicates that the OK button was selected.

IDCANCEL (2)

Indicates that the CANCEL button was selected.

< 0

Indicates that the function was unable to display the dialog.

If bCreate is TRUE, this function returns one of the following values:

SelectDir Return Values when bCreate is TRUE

Return Value

Description

IDCANCEL (2)

Indicates that the CANCEL button was selected.

0

Indicates that the OK button was selected and the function was able to create the folder specified, if necessary.

< 0

Indicates that the function failed to display the dialog and/or create the specified folder.

Additional Information

The dialog that is displayed by this function cannot be displayed with a skin; it appears the same, regardless of whether you have specified a skin.
In early versions of InstallShield Professional, when bCreate was set to TRUE and the end user selected a folder that did not exist, a confirmation message box was displayed asking whether the folder should be created. This message box proved to be confusing to many end users, so it has been removed from InstallShield.

See Also