InstallShield

Installshield (example password dialog)

aucd29 2013. 9. 27. 13:20
////////////////////////////////////////////////////////////////////////////////
//
// IIIIII SSSSSS
//    II    SS                         InstallShield (R)
//    II    SSSSSS     (c) 1996-2001, InstallShield Software Corporation
//    II        SS     (c) 1990-1996, InstallShield Corporation
// IIIIII SSSSSS                     All Rights Reserved.
//
//
//    File Name: Setup.rul
//
// Description: Example Custom Password Dialog script.
//
//                Shows a password dialog box that disables the Next
//                button until the user enters a valid password.
//
//     Comments: See Custom_Password.rul for the implementation and
//                the expected serial-number format.
//
//                The example does not install any files; the
//                warning -1527 generated at build time can be ignored.
//
////////////////////////////////////////////////////////////////////////////////

// Include header files

#include "ifx.h"
#include "winapi.h"
#include "Custom_Password.rul"

///////////////////////////////////////////////////////////////////////////////
//
//     FUNCTION: OnFirstUIBefore
//
// PURPOSE: This Event Handler manages the display and navigation of
//            the standard dialogs that exist in a setup.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore( )
    NUMBER nResult, nSetupType;
    STRING szTitle, szMsg;
    STRING svName, svCompany;
    STRING szDir;
    // the three fields of the password dialog box
    STRING svSerial_1, svSerial_2, svSerial_3;

begin

    Enable(DIALOGCACHE);

    nSetupType = TYPICAL;
    szDir = INSTALLDIR;

    svName    = "";
    svCompany = "";

    // by default, all password fields are empty
    svSerial_1 = "";
    svSerial_2 = "";
    svSerial_3 = "";

Dlg_Start:
    // beginning of dialogs label

Dlg_SdWelcome:
    szTitle = "Example Custom Password Dialog";
    szMsg = "The following dialog is a custom password dialog box, which " +
             "illustrates disabling the Next button until the user enters a valid password. " +
             "See Custom_Password.rul for the expected password format.";
    nResult = SdWelcome( szTitle, szMsg );
    if (nResult = BACK) goto Dlg_Start;

    ///////////////////////////////////////////////////////////
    // Display the custom password dialog;
    // the code for the custom dialog can be viewed in
    // Custom_Password.rul
    ///////////////////////////////////////////////////////////

Dlg_SdCustomRegisterUserEx:
    szTitle = "";
    szMsg = "Note how the Next button is disabled until you enter a valid serial number. " +
             "See Custom_Password.rul for the implementation.";
    nResult = SdCustomRegisterUserEx( szTitle, szMsg, svName, svCompany, svSerial_1, svSerial_2,svSerial_3 );
    if (nResult = BACK) goto Dlg_SdWelcome;

    ///////////////////////////////////////////////////////////
    // This is redundant; however, in case the user uses a spy
    // program and enables the Next button without entering a
    // valid serial number, we check again.
    ///////////////////////////////////////////////////////////

    if (!SdCustomRegExValidatePassword( svSerial_1, svSerial_2, svSerial_3 )) then
        MessageBox(
            "You entered an invalid serial number; please enter a valid serial number.",
            SEVERE);
        goto Dlg_SdCustomRegisterUserEx;
    endif;

    ///////////////////////////////////////////////////////////
    // end Custom Dialog code
    ///////////////////////////////////////////////////////////

Dlg_SdAskDestPath:
    szMsg = "This example does not install any files; " +
            "click Cancel to exit the InstallShield wizard.";
    nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
    INSTALLDIR = szDir;
    if (nResult = BACK) goto Dlg_SdCustomRegisterUserEx;

    return 0;
end;