HandlerEx 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

*

* Demonstrates the HandlerEx function.

*

* This script shows how to install error and help handlers in

* an installation.

*

* First, the handlers are installed. Then Sd dialogs are

* displayed to the end user. The handler code is invoked if

* the end user presses F1 (help) or clicks the cancel

* button while the dialogs are displayed.

*

* Note that the script uses the InstallScript Language

* Reference and Help Library help files for demonstration purposes.

* Insert copies of these files (Langref.chm and HelpLib.chm from

* the InstallShield Program Files Folder\Program folder) in the

* Language Independent area of the Support Files/Billboards view.

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

 

// Included header files ----------------------------------------------------

#include "ifx.h"

 

export prototype void ExFn_Handler();

prototype OnHelp_Handler();

prototype OnExit_Handler();

 

// Define help topic IDs

#define HELP_WELCOME 101

#define HELP_REGISTERUSER 102

 

INT nHelpID;

 

function void ExFn_Handler()

    STRING svName, svCompany, szMsg;

begin

    // Install the help handler.

    HandlerEx (HELP, OnHelp_Handler);

 

    // Install the exit handler.

    HandlerEx (EXIT, OnExit_Handler);

 

    // Set message for display in dialogs.

    szMsg = "Press F1 to display InstallShield's " +

        "help for this dialog.\n" +

        "Press Cancel to invoke the custom exit handler.";

 

WelcomeDialog:

    // Set the help topic ID.

    nHelpID = HELP_WELCOME;

 

    // Display the Welcome dialog.

    SdWelcome ("SdWelcome Dialog", szMsg);

 

    // Set the help topic ID.

    nHelpID = HELP_REGISTERUSER;

 

    if SdRegisterUser ("Register", szMsg, svName, svCompany) = BACK then

        // Go back to the Welcome dialog.

        goto WelcomeDialog;

    endif;

 

end;

 

function OnHelp_Handler()

    STRING szHelpTopic;

begin

    // Set the topic to be displayed from the help.

    switch (nHelpID)

        case HELP_WELCOME : szHelpTopic = "5223 ";

        case HELP_REGISTERUSER : szHelpTopic = "5211 ";

    endswitch;

 

    // Launch the InstallScript language reference and

    // display the selected help topic.

 

    LaunchApplication (WINDIR ^ "hh.exe", "-mapid " + szHelpTopic +

                        SUPPORTDIR ^ "Help_Lib.chm",

                        "", SW_SHOW, INFINITE, LAAW_OPTION_WAIT);

end;

 

function OnExit_Handler()

begin

    // Ask for confirmation to abort.

    if AskYesNo ("Do you really want to exit?", FALSE) = YES then

        // Abort the setup.

        abort;

    else

        // Return to the setup.

        return 0;

    endif;

end;