InstallShield

InstallShield Guide

aucd29 2013. 9. 27. 13:20
// --------------------------------------------------------------------------
// September 12, 2006
// --------------------------------------------------------------------------
// * Coder : aucd29 (aucd29@gmail.com)
//
// * -_ - 별거 아닌 InstallShield 맨땅에 헤딩하려니 삽질 느낌 나3.
// * rul 이 VBScript인줄 알았는데 ... 자체적인 스크립트인듯.... -_ - 문법이
// C와 VB를 적당히 섞어버린... 묘한.. -_ -;
//

//===========================================================================
//
// File Name:    Setup.rul
//
// Description: Blank setup main script file
//
// Comments:     Blank setup is an empty setup project. If you want to
//                 create a new project via. step-by step instructions use the
//                 Project Assistant.
//
//===========================================================================

// Included header files ----------------------------------------------------
#include "ifx.h"

// 추가적으로 내가 사용할 시리얼키 체크 루틴!
#include "CheckingSerialKey.rul"

//prototype cdecl BOOL CheckSerial(byref string);

//---------------------------------------------------------------------------                                                                        
// OnFirstUIBefore
//
// First Install UI Sequence - Before Move Data
//
// The OnFirstUIBefore event is called by OnShowUI when the setup is
// running in first install mode. By default this event displays UI allowing
// the end user to specify installation parameters.
//
// Note: This event will not be called automatically in a
// program...endprogram style setup.
//---------------------------------------------------------------------------
function OnFirstUIBefore()
    number nResult;
    number nLevel;
    number nvSize, nSetupType;
    number nId;
    string szTitle, szMsg;
    string szOpt1, szOpt2, szLicenseFile;
    string szName, szCompany;
    string szTargetPath;
    string svDir;
    string szFeatures, szTargetdir;    
    string szId;
    BOOL    bLicenseAccepted;    
    string szSerial;    
    BOOL     bLoadDll;
begin    

    nSetupType = COMPLETE;    
            
    if ( ALLUSERS ) then
        TARGETDIR = PROGRAMFILES ^ IFX_COMPANY_NAME ^ IFX_PRODUCT_NAME;        
    else
        TARGETDIR = FOLDER_APPDATA ^ IFX_COMPANY_NAME ^ IFX_PRODUCT_NAME;
    endif;

    // Customize the default TARGETDIR for multi-instance application.
    // TODO: If you want something different customize the code below.    
    if( MAINT_OPTION = MAINT_OPTION_MULTI_INSTANCE && MULTI_INSTANCE_COUNT > 0) then

        // Start with the current multi-instance count plus one.
        nId = MULTI_INSTANCE_COUNT + 1;

        // Find a unique TARGETDIR.
        while( ExistsDir( TARGETDIR ) = EXISTS )
            
            // Convert to string.
            NumToStr( szId, nId );
            
            // Update IFX_MULTI_INSTANCE_SUFFIX
            IFX_MULTI_INSTANCE_SUFFIX = "_" + szId;
        
            // Update TARGETDIR
            TARGETDIR = TARGETDIR + IFX_MULTI_INSTANCE_SUFFIX;
            
            // Update nId
            nId = nId + 1;

        endwhile;

    endif;

    svDir = TARGETDIR;
    szName = "";
    szCompany = "";
    bLicenseAccepted = FALSE;

// Beginning of UI Sequence
Dlg_Start:
    nResult = 0;

Dlg_SdWelcome:
    szTitle = "";
    szMsg = "";
    //{{IS_SCRIPT_TAG(Dlg_SdWelcome)
    nResult = SdWelcome( szTitle, szMsg );
    //}}IS_SCRIPT_TAG(Dlg_SdWelcome)
    if (nResult = BACK) goto Dlg_Start;

Dlg_SdLicense2:
    szTitle = "";
    szOpt1 = "";
    szOpt2 = "";
    //{{IS_SCRIPT_TAG(License_File_Path)
    szLicenseFile = SUPPORTDIR ^ "license.txt";
    //}}IS_SCRIPT_TAG(License_File_Path)
    //{{IS_SCRIPT_TAG(Dlg_SdLicense2)
    // nResult = SdLicense2( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
    //}}IS_SCRIPT_TAG(Dlg_SdLicense2)
    if (nResult = BACK) then
        goto Dlg_SdWelcome;
    else
        bLicenseAccepted = TRUE;
    endif;

// 내가 추가한 시리얼 키 부분
// 고냥 다이얼로그 쪽에 체크 박스 On 해준뒤에 띄우면 되3...
Dlg_SdRegisterUserEx:
    // Input Serial Key
    szMsg = "";
    szTitle = "";
    szSerial = "";

    // 다이얼로그에서 내용을 가져오도록 하고.
    nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial );

    // 만약 BACK 버튼을 선택했다면 위로 다시 보내고
    if (nResult = BACK) goto Dlg_SdLicense2;

    // 내가 만든 체크 루틴에서 FALSE 가되면 메시지를 보인 뒤 다시금
    // 시리얼키 보이는 다이얼 로그를 띄운다.
    if(CheckSerial(szSerial) = FALSE) then
        MessageBox("Error!! Invalid Serial Number", WARNING);
        goto Dlg_SdRegisterUserEx;
    endif;

Dlg_ObjDialogs:
    nResult = ShowObjWizardPages( nResult );
    if (nResult = BACK) goto Dlg_SdRegisterUserEx;
    
Dlg_SdStartCopy2:
    szTitle = "";
    szMsg = "";
    //{{IS_SCRIPT_TAG(Dlg_SdStartCopy2)    
    nResult = SdStartCopy2( szTitle, szMsg );    
    //}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
    if (nResult = BACK) goto Dlg_ObjDialogs;

    return 0;
end;

/////////////////////////////////////////////////////////////////
// CheckingSerialKey.rul 요 파일이3

// --------------------------------------------------------------
// DEFINITION PROTOTYPE
// --------------------------------------------------------------
prototype CheckSerial(byref string);

// --------------------------------------------------------------
// September 11, 2006
// --------------------------------------------------------------
// * Check SerialKey Rountine
//

function CheckSerial(szSerial)
    string szWordCheck;
begin
    // 시리얼키 길이 검사하는데 17자여만 한다.
    if (StrLength(szSerial) != 17) then
        return FALSE;
    endif;
    
    nRes = 0;
    for i=0 to 3
        // 1차 적으로 검사 루틴
    endfor;

    // 2차적으로 검사 루틴
    if (nRes == 맞는값?)
    {
        return TRUE;
    }

    return FALSE;
end;