AddFeature Method

InstallShield 2022 » Automation Interface

Project:This information applies to the following project types:

Basic MSI
InstallScript
InstallScript MSI

The AddFeature method creates a feature with the specified name. AddFeature is a member of ISWiProject. The new feature is added to the current project as a top-level feature, but when this method is a member of an ISWiFeature object, the new feature is added as a subfeature of the current feature.

The feature is created with the same default properties that new features have when you add them in InstallShield.

After you have added the feature, you can set its other properties and associate components with it.

Syntax

AddFeature (FeatureKey As String) As ISWiFeature

Parameters

AddFeature Method Parameters

Parameter

Description

FeatureKey

The feature key is the same as the name of the feature that is displayed in the Setup Design and Features views. The name becomes the index for the new ISWiFeature object. This string must contain only alphanumeric characters, dots (.), or underscores (_), and it must begin with a letter or an underscore. FeatureKey must be unique among your project's feature names.

Feature names are case-sensitive.

Example

The following Visual Basic lines demonstrate calling AddFeature to add a feature, a subfeature, and then associate an existing component with the subfeature:

    Dim pProject As ISWiProject

    

    Set pProject = New ISWiProject

    pProject.OpenProject "C:\MySetups\SampleApp.ism"

    

    Dim pFeat1, pFeat2 As ISWiFeature

    Dim sFeat1Name, sFeat2Name As String

    

    sFeat1Name = "ParentFeature"

    sFeat2Name = "SubFeature"

    

    ' Add the feature ParentFeature, then SubFeature under ParentFeature

    Set pFeat1 = pProject.AddFeature(sFeat1Name)

    Set pFeat2 = pFeat1.AddFeature(sFeat2Name)

    

    Dim pComp

    Dim sCompName As String

 

    ' Add the existing component NewComponent1 to SubFeature

    sCompName = "NewComponent1"

    Set pComp = pProject.ISWiComponents.Item(sCompName)

    pFeat2.AttachComponent pComp

    

    pProject.SaveProject

    pProject.CloseProject

Applies To

ISWiProject 
ISWiFeature