FeatureFilterOS Example

InstallShield 2014 ยป InstallScript Language Reference

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

*

* InstallShield Example Script

*

* Demonstrates the FeatureFilterOS function.

*

* To run this script, create a blank setup project.

* Specify Windows 95, Windows 98, and Windows NT 4.0

* (Intel) for operating systems in the Components view.

* Use release flags to specify which platforms to include

* in the build. Specify Windows 95, Windows 98, and Windows

* NT 4.0 (Intel). When you run the Release Wizard, enter the

* release flags in the Filtering Settings panel.

*

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

 

// You can convert the following define statements into string

// entries to localize your setup.

#define  COMPANY_NAME         "MultiLangOS Inc."

#define  PRODUCT_NAME         "MultiLangOS"

#define  PRODUCT_VERSION      "1.0"

#define  PROGRAMFOLDER        "MultiLangOS"

#define  PRODUCT_KEY          "Mlangos.exe"

#define  DEINST_KEY           "MultiLangOS"

#define  ASKDESTTITLE         "Destination Location"

#define  ASKDESTMSG           "Select a destination location."

#define  COMPERRTITLE         "Data Transfer Error Information"

#define  COMPERRMSG1          "FeatureError returned the following error."

#define  COMPERRMSG2          "Setup will now abort."

#define  COMPERRMSG3          "Media Name:"

#define  COMPERRMSG4          "Feature:"

#define  COMPERRMSG5          "Component:"

#define  COMPERRMSG6          "File:"

#define  COMPERRMSG7          "Error Number:"

 

    prototype HandleFeatureError (NUMBER);

 

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

#include "Ifx.h"

 

export prototype ExFn_FeatureFilterOS(HWND);

 

function ExFn_FeatureFilterOS(hMSI)

    STRING  svResult, svDir, svLogFile;

    NUMBER  nvResult, nvDisk;

begin

 

    // Disable the Back button in setup dialogs.

    Disable (BACKBUTTON);

 

    // Set up uninstallation and get destination location.

    InstallationInfo(COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY);

 

    INSTALLDIR = PROGRAMFILES ^ PROGRAMFOLDER;

 

    AskDestPath (ASKDESTTITLE, ASKDESTMSG, INSTALLDIR , 0 );

 

    DeinstallStart (INSTALLDIR, svLogFile, DEINST_KEY, 0);

 

    RegDBSetItem (REGDB_UNINSTALL_NAME, DEINST_KEY);

    

    // Get the operating system and call FeatureFilterOS

    // to filter the operating systems that are not present.

    GetSystemInfo (OS, nvResult, svResult);

 

    switch (nvResult)

        case IS_WINDOWSNT:

            GetSystemInfo (WINMAJOR, nvResult, svResult);

            if (nvResult = 4) then

                // It's NT 4.0, so filter Windows 95 and Windows 98.

                FeatureFilterOS (MEDIA, 0, ISOSL_WIN95, TRUE);

                FeatureFilterOS (MEDIA, 0, ISOSL_WIN98, TRUE);

            else

                MessageBox ("Target system OS not supported.", SEVERE);

                abort;

            endif;

        case IS_WINDOWS9X:

            // It's Windows 95 or 98, so filter Windows NT 4.0.

            FeatureFilterOS (MEDIA, 0, ISOSL_NT40, TRUE);

 

            // Determine if it's Windows 95 or Windows 98.

            GetSystemInfo (WINMINOR, nvResult, svResult);

 

            if (nvResult < 10) then

                // It's Windows 95, so filter Windows 98 too.

                FeatureFilterOS (MEDIA, 0, ISOSL_WIN98, TRUE);

            else

                // It's Windows 98, so filter Windows 95 too.

                FeatureFilterOS (MEDIA, 0, ISOSL_WIN95, TRUE);

            endif;

        default:

            MessageBox ("Target system OS not supported.", SEVERE);

            abort;

    endswitch;

 

    // Transfer files to target system.

    nvResult = FeatureMoveData (MEDIA, nvDisk, 0);

 

    if (nvResult < 0) then

        HandleFeatureError (nvResult);

    endif;

 

end;

 

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

*

* Function:  HandleFeatureError

*

*  Purpose:  This function evaluates the value returned by a feature

*            function and if the value is less than zero, displays the error

*            number and aborts the setup.

*

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

function HandleFeatureError( nResult )

  NUMBER  nvError;

  STRING  svFeatureSource, svFeature, svComponent, svFile;

begin

  FeatureError (svFeatureSource, svFeature, svComponent, svFile, nvError);

  SprintfBox(INFORMATION, FEATERRTITLE,

            FEATERRMSG1 + "\n" + FEATERRMSG2 + "\n\n" +

            FEATERRMSG3 + " %s\n" + FEATERRMSG4 + " %s\n" +

            FEATERRMSG5 + " %s\n" + FEATERRMSG6 + " %s\n" +

            FEATERRMSG7 + " %ld",

            svFeatureSource, svFeature, svComponent, svFile, nvError);

  abort;

end;