FeatureGetData Example

InstallShield 2014 ยป InstallScript Language Reference

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

*

* InstallShield Example Script

*

* Demonstrates the FeatureGetData function.

*

* This example script demonstrates a function that retrieves

* information about a specified feature.

*

*  Comments:  To run this example script, create a project (or

*             insert into a project) with features and/or

*             subfeatures with components containing files.

*

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

 

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

#include "Ifx.h"

 

// Include iswi.h for Windows Installer API function prototypes and constants,

// and to declare code for the OnBegin and OnEnd events.

#include "iswi.h"

 

    // The keyword export identifies MyFunction() as an entry-point function.

    // The argument it accepts must be a handle to the Installer database.

    export prototype MyFunction(HWND);

        

    // To Do:  Declare global variables, define constants, and prototype user-

    //         defined and DLL functions here.

 

function MyFunction(hMSI)

 

    STRING  svDir, szTitle, szMsg, svResult;

    NUMBER  nvResult;

  

begin

 

    svDir   = INSTALLDIR;

    szTitle = "Select Features";

    szMsg   = "Select the features you want to install on your computer.";

    

    // Display available features.

    SdFeatureTree (szTitle, szMsg, svDir, "", 2);

        

    // Get the description property for Feature1.

    FeatureGetData (MEDIA, "Feature1", feature_FIELD_DESCRIPTION, nvResult, svResult);

          

    // Display the description for Feature1.

    MessageBox ("Feature1's description is: " + svResult, INFORMATION);

          

    // Determine whether or not Feature2 is selected.

    FeatureGetData (MEDIA, "Feature2", feature_FIELD_SELECTED, nvResult, svResult);

          

    // Display a message indicating whether or not Feature2 is selected.

    if nvResult=0  then

     MessageBox ("Feature2 is not selected.", INFORMATION);

    else

     MessageBox ("Feature2 is selected.", INFORMATION);

    endif;    

    

end;