zoukankan      html  css  js  c++  java
  • InstallShield 收藏

    function OnFirstUIBefore()
        number nResult, nLevel, nSize, nSetupType;
        string szTitle, szMsg, szOpt1, szOpt2, szLicenseFile,szKeyRoot;
        string szName, szCompany, szTargetPath, szDir, szFeatures;
        BOOL    bLicenseAccepted;    
        string szExePath,szCmdPath;
    begin 
       
        nSetupType = COMPLETE; 
        szDir = 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.rtf";
        //}}IS_SCRIPT_TAG(License_File_Path)
        //{{IS_SCRIPT_TAG(Dlg_SdLicense2)
        nResult = SdLicense2Rtf( szTitle, szOpt1, szOpt2, szLicenseFile, bLicenseAccepted );
        //}}IS_SCRIPT_TAG(Dlg_SdLicense2)
        if (nResult = BACK) then
            goto Dlg_SdWelcome;
        else
            bLicenseAccepted = TRUE;
        endif;
    
    Dlg_SdRegisterUser:
        szMsg = "";
        szTitle = "";
        //{{IS_SCRIPT_TAG(Dlg_SdRegisterUser) 
        nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
        //}}IS_SCRIPT_TAG(Dlg_SdRegisterUser)
        if (nResult = BACK) goto Dlg_SdLicense2;
    
    Dlg_SetupType2:   
        szTitle = "";
        szMsg = "";
        nResult = CUSTOM;
        //{{IS_SCRIPT_TAG(Dlg_SetupType2) 
        nResult = SetupType2( szTitle, szMsg, "", nSetupType, 0 );
        //}}IS_SCRIPT_TAG(Dlg_SetupType2)
        if (nResult = BACK) then
            goto Dlg_SdRegisterUser;
        else
            nSetupType = nResult;
            if (nSetupType != CUSTOM) then
                szTargetPath = TARGETDIR;
                nSize = 0;
                FeatureCompareSizeRequired( MEDIA, szTargetPath, nSize );
                if (nSize != 0) then      
                    MessageBox( szSdStr_NotEnoughSpace, WARNING );
                    goto Dlg_SetupType2;
                endif;
            endif;   
        endif;
    
    Dlg_SdAskDestPath2:
        if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType2;
    szTitle = "";
        szMsg = "";
        if (nSetupType = CUSTOM) then
                    //{{IS_SCRIPT_TAG(Dlg_SdAskDestPath2) 
       nResult = SdAskDestPath2( szTitle, szMsg, szDir );
                    //}}IS_SCRIPT_TAG(Dlg_SdAskDestPath2)
            TARGETDIR = szDir;
        endif;
        if (nResult = BACK) goto Dlg_SetupType2;
    
    Dlg_SdFeatureTree: 
        if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2;
        szTitle = "";
        szMsg = "";
        szFeatures = "";
        nLevel = 2;
        if (nSetupType = CUSTOM) then
            //{{IS_SCRIPT_TAG(Dlg_SdFeatureTree) 
            nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel );
            //}}IS_SCRIPT_TAG(Dlg_SdFeatureTree)
            if (nResult = BACK) goto Dlg_SdAskDestPath2; 
        endif;
    
    Dlg_SQLServer:
        nResult = OnSQLServerInitialize( nResult );
        if( nResult = BACK ) goto Dlg_SdFeatureTree;
    
    Dlg_ObjDialogs:
        nResult = ShowObjWizardPages( nResult );
        if (nResult = BACK) goto Dlg_SQLServer;
        
    Dlg_SdStartCopy2:
        szTitle = "";
        szMsg = "";   
        //显?示?各?种?路?径?
        MessageBox("TARGETDIR=" + TARGETDIR + "\n"
        +"SUPPORTDIR=" + SUPPORTDIR + "\n" 
        +"WINSYSDIR=" + WINSYSDIR + "\n" 
        +"DISK1TARGET=" + DISK1TARGET + "\n" 
        +"<FOLDER_APPLICATIONS>=" + FOLDER_APPLICATIONS + "\n" 
        +"<IFX_COMPANY_NAME>=" + IFX_COMPANY_NAME + "\n" 
        +"<IFX_PRODUCT_NAME>=" + IFX_PRODUCT_NAME + "\n"
        +"szOpt2=" + szOpt2 + "\n"
        +"szLicenseFile=" + szLicenseFile + "\n"   
        +"szTargetPath=" + szTargetPath + "\n" 
        +"szDir=" + szDir + "\n"   
        +"szFeatures=" + szFeatures + "\n"
        +"szOpt1=" + szOpt1 + "\n",MB_YESNO);   
        //开?始?安?装?其?他?的?程?序?
        szExePath = SUPPORTDIR ^ "test.exe";     //这?个?是?放?入?缓?存?文?件?夹?里?面?执?行?,执?行?完?后?自?动?删?除?
        //添?加?缓?存?文?件?夹?步?骤?
        //1.选?择?Support Files /Billboards ->Language IndePendent -> INsert File 
        
        //安?装?其?他?程?序?
        //只?能?判?断?程?序?执?行?没?执?行?不?能?判?断?执?行?安?装?成?功?,需?要?通?过?读?取?注?册?表?来?判?断?
        //if LaunchAppAndWait (szExePath, "", WAIT) < 0 then 
        //   MessageBox("不?能?安?装?该?程?序?,本?次?安?装?失?败?!",SEVERE); 
        //   abort; 
        //endif; 
         
        //执?行?Bat文?件?
        //szExePath = SUPPORTDIR ^ "test.bat"; 
        //if LaunchAppAndWait (szExePath, "", WAIT) < 0 then 
        //   MessageBox("bat程?序?执?行?失?败?",SEVERE); 
        //   abort; 
        //endif; 
        
        //执?行?CMd命?令?  /c 注?意?这?个?/ 不?是?\记?住?
       // szExePath = WINSYSDIR^ "cmd.exe"; 
       // if LaunchAppAndWait (szExePath, "/c del c:\\01.txt", WAIT) < 0 then 
        //   MessageBox("CMD执?行?失?败?",SEVERE); 
        //   abort; 
        //endif;   
        
        //执?行?RegSvr32注?册?组?件?命?令?
        //szExePath = "/s C:\\Example\\原?始?文?件?\\jmail.dll"; //注?意?/s 参?数?要?放?在?参?数?命?令?里?
       // if LaunchAppAndWait (WINSYSDIR ^ "Regsvr32", szExePath , WAIT) < 0 then 
        //   MessageBox("注?册?组?件?执?行?失?败?",SEVERE); 
        //   abort; 
        //endif;    
        
        //取?消?注?册?
        //szExePath = "/s /u C:\\Example\\原?始?文?件?\\jmail.dll"; // /u 卸?载?
       // if LaunchAppAndWait (WINSYSDIR ^ "Regsvr32", szExePath , WAIT) < 0 then 
        //   MessageBox("取?消?注?册?组?件?执?行?失?败?",SEVERE); 
        //   abort; 
        //endif;    
           
        //关?闭?服?务?
        //szExePath = WINSYSDIR^ "NET"; 
        //if LaunchAppAndWait (szExePath, "STOP   MSSQLSERVER", WAIT) < 0 then 
        //   MessageBox("关?闭?服?务?失?败?",SEVERE); 
        //   abort; 
       // endif; 
        
        //开?启?服?务?
        //szExePath = WINSYSDIR^ "NET"; 
        //if LaunchAppAndWait (szExePath, "START   MSSQLSERVER", WAIT) < 0 then 
        //   MessageBox("开?启?服?务?失?败?",SEVERE); 
       // abort; 
        //endif;   
        
        // ServiceAddService 添?加?服?务?ServiceRemoveService 删?除?服?务?
        //ServiceExistsService 判?断?服?务?是?否?存?在?ServiceGetServiceState 检?查?服?务?是?否?启?动?
        //if MessageBox("是?否?关?闭?服?务?!",MB_YESNO) = IDYES then     
        // ServiceStopService("MSSQLSERVER");
        //endif; 
          
        //if MessageBox("是?否?开?启?服?务?!",MB_YESNO) = IDYES then     
        // ServiceStartService("MSSQLSERVER","");
        //endif; 
        
        if MessageBox("是?否?退?出?本?次?安?装?!",MB_YESNO) = IDYES then     
        abort;
        endif; 
            
        //{{IS_SCRIPT_TAG(Dlg_SdStartCopy2) 
        nResult = SdStartCopy2( szTitle, szMsg ); 
        //}}IS_SCRIPT_TAG(Dlg_SdStartCopy2)
        if (nResult = BACK) goto Dlg_ObjDialogs;
        
        //这?里?开?始?写?注?册?表?
        RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); //设?置?注?册?表?函?数?默?认?值?
        //szKeyRoot = "SOFTWARE\\ISsample" ; //需?创?建?多?个?子?项?时?要?一?个?一?个?创?建?否?则?卸?载?不?了?
        //RegDBCreateKeyEx (szKeyRoot , "" ); //了?用?""代?替?类?
        //设?置?键?值?  size = -1 InstallShield自?动?设?置?大?小?
        //RegDBSetKeyValueEx(szKeyRoot,"config_string",REGDB_STRING,"Hello",-1);
        //RegDBSetKeyValueEx(szKeyRoot,"config_numer",REGDB_NUMBER,"1",-1); 
        
        //在?本?身?创?建?的?目?录?下?写?注?册?表?   
        szKeyRoot = "SOFTWARE"^IFX_COMPANY_NAME^IFX_PRODUCT_NAME ; 
        RegDBSetKeyValueEx(szKeyRoot,"Path",REGDB_STRING,TARGETDIR,-1);
        RegDBSetKeyValueEx(szKeyRoot,"config",REGDB_NUMBER,"1",-1);
        
        // Added in 11.0 - Set appropriate StatusEx static text.
        SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) );
    
        return 0;
    end;
    
    //---------------------------------------------------------------------------
    // OnMaintUIBefore
    // 卸?载?向?导?页?
    //---------------------------------------------------------------------------
    function OnMaintUIBefore()
        number nResult, nType, nMediaFlags;
        string szTitle, szMsg, szIgnore; 
        string szKeyRoot,szPath ,szConfigStr;
        int szConfig; 
        NUMBER   nType1,nType2,nvSize;   //提?取?注?册?表?时?,一?定?要?把?他?转?换?成?这?种?数?据?类?型?,否?则?出?错?
    begin
    //显?示?注?册?表?值?
    nType1 =   REGDB_STRING;
    nType2 =   REGDB_NUMBER;
    nvSize = -1;
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); 
    szKeyRoot = "SOFTWARE"^IFX_COMPANY_NAME^IFX_PRODUCT_NAME; 
    //RegDBSetKeyValueEx (szKeyRoot, "Path", nType1, "Hello",nvSize);//看?能?否?取?到?值?
    RegDBGetKeyValueEx (szKeyRoot, "Path", nType1, szPath,nvSize); 
    //RegDBGetKeyValueEx (szKeyRoot, "config",nType2, szConfig,nvSize);
    MessageBox("路?径?:" + szKeyRoot + "注?册?表?值?:"+ szPath ,MB_YESNO);
    
    // nType defaults to MODIFY.
    nType = MODIFY; //可?修?改?这?个?默?认?值?
        //Initialize SQL
        OnSQLServerInitializeMaint();
    
    // Beginning of UI Sequence
    Dlg_Start:
    
        // Added in Version 9.5 - Support for REMOVEONLY option.
        if( !REMOVEONLY ) then
        // In standard mode show maintenance dialog
         Disable( BACKBUTTON );
         nType = SdWelcomeMaint( szTitle, szMsg, nType );
         Enable( BACKBUTTON );
            nResult = NEXT;
        else
            // Hide the initial progress dialog as otherwise the user can
            // click on it, and hide the MessageBox.
            Disable( DIALOGCACHE );
    
            // In RemoveOnly mode, set to remove.
            nType = REMOVEALL;
        endif;
    
    // Show Uninstall Confirmation Dialog
        if ( nType = REMOVEALL ) then          //删?除?事?件?
       nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO );
       if (nResult != IDYES ) then
                
                if( REMOVEONLY ) then
                    // In REMOVEONLY mode, abort the setup.
                    abort;
                else
                    // In non-REMOVEONLY mode, redisplay the previous dialog.
           goto Dlg_Start;
                endif;
    
       endif;
    endif;
    
    Dlg_SdFeatureTree:
    if ( nType = MODIFY ) then
       szTitle = "";
       szMsg = SdLoadString( SD_STR_COMPONENT_MAINT_MSG );
       nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, "", -1 );
       if ( nResult = BACK ) goto Dlg_Start;
        endif;
    
    Dlg_ObjDialogs:
        nResult = ShowObjWizardPages( nResult );
        if ( ( nResult = BACK ) && ( nType != MODIFY ) ) goto Dlg_Start;
        if ( ( nResult = BACK ) && ( nType = MODIFY ) ) goto Dlg_SdFeatureTree;
    
    switch(nType)
    
            case REMOVEALL:          //卸?载?调?用?(有?卸?载?有?做?的?动?作?都?可?以?放?到?这?里?来?)
          
        // Ensure that all previously installed features are removed
        // for media that supports updating.
        MediaGetData( MEDIA, MEDIA_FIELD_MEDIA_FLAGS, nMediaFlags, szIgnore );
       
        if( nMediaFlags & MEDIA_FLAG_UPDATEMODE_SUPPORTED ) then
         FeatureRemoveAllInMediaAndLog();
        else
         FeatureRemoveAllInMedia();
        endif;
    
                // Added in 11.0 - Set appropriate StatusEx static text.
                SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) );
    
            case REPAIR:       //修?复?
        
        // Changed for DevStudio 9, Disk1 files are now always updated when installed
        // so when running from ADDREMOVE we need to prevent these files from being
        // updated since this will result in files being updated that are locked by the setup.
        // Updating these files when running from ADDREMOVE should not be needed since updates
        // are not run directly from Add/Remove.
                if( ADDREMOVE ) then
                    // Reinstall all previously installed features, except
                    // disk1 features.
                    FeatureUpdate( "" );
                else
                    // Reinstall all previously installed features.
                    FeatureReinstall();
                endif;
    
                // Added in 11.0 - Set appropriate StatusEx static text.
                SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) );
    
            case MODIFY:           //修?改?事?件?
                
                // Added in 11.0 - Set appropriate StatusEx static text.
                SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_MODIFY ) );
    
        endswitch;
    
    end;
    
    
    //---------------------------------------------------------------------------
    // OnFirstUIAfter
    // 安?装?完?成?后?,点?完?成?前?发?生?的?事?件?
    //
    //---------------------------------------------------------------------------
    function OnFirstUIAfter()
        STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
        NUMBER bvOpt1, bvOpt2;
    NUMBER bShowUpdateServiceDlg;
    begin
        //MessageBox("开?始?了?OnFirStUIAfter!",MB_YESNO ) ;
        ShowObjWizardPages(NEXT);
        
        szTitle = "";
        szMsg1 = ""; 
        szMsg2 = "";
        szOpt1 = "";
        szOpt2 = "";
    bvOpt1   = FALSE;
        bvOpt2   = FALSE;  
    
    // Set this to true if you have the update service enabled, and if you want to check for updates.
    // Note: the ISUS Starter Edition does not support checking for updates programatically. So, 
    // only set this to true if you have at least the ISUS Professional Edition.
    bShowUpdateServiceDlg = FALSE;
        
        //{{IS_SCRIPT_TAG(Dlg_SdDinishEx) 
        
        if ( BATCH_INSTALL ) then
        SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
        else
    
       // If the update service is enabled, show finish dialog that includes
       // update check option.
       if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then
    
        if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then
    
         // Don't check for updates in silent mode.
         if( MODE != SILENTMODE ) then
          UpdateServiceCheckForUpdates( "", FALSE );
         endif;
    
        endif;
    
       else
        SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 );
       endif;
    
        endif;
        //}}IS_SCRIPT_TAG(Dlg_SdDinishEx) 
    end;
    
    
    //---------------------------------------------------------------------------
    // OnAbort
    //取?消?按?钮?退?出?,最?后?点?完?成?发?生?事?件?
    //---------------------------------------------------------------------------
    function OnAbort()
    begin     
    //MessageBox("发?生?OnAbort事?件?!", MB_YESNO ) ;
    end;
    //---------------------------------------------------------------------------
    // OnUpdateUIAfter
    //
    // Update Mode UI Sequence - After Move Data
    //
    // The OnUpdateUIAfter event called by OnShowUI after the file transfer
    // of the setup when the setup is running in update mode. By default
    // this event displays UI that informs the end user that the maintenance setup
    // has been completed successfully.
    //
    // Note: This event will not be called automatically in a
    // program...endprogram style setup.
    //---------------------------------------------------------------------------
    function OnUpdateUIAfter()
        string szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
        BOOL bOpt1, bOpt2;
    begin
        MessageBox("OnUninstall", MB_YESNO ) ;
        ShowObjWizardPages(NEXT);
        
    szTitle = SdLoadString(IDS_IFX_SDFINISH_UPDATE_TITLE);    
        szMsg1 = SdLoadString(IDS_IFX_SDFINISH_UPDATE_MSG1);
    szMsg2 = "";    
        szOpt1 = "";
        szOpt2 = "";
    bOpt1   = FALSE;
        bOpt2   = FALSE;    
        
        if ( BATCH_INSTALL ) then
        SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 );
        else    
           SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bOpt1 , bOpt2 );
        endif;
    end;
    
    
    //---------------------------------------------------------------------------
    // OnShowUI
    //在?第?一?次?弹?出?向?导?页?发?生?
    //---------------------------------------------------------------------------
    function OnShowUI()
    BOOL bMaintenanceMode, bUpdateMode;
    string szIgnore, szTitle;
    begin
       //MessageBox("OnShowUI", MB_YESNO ) ;
       // Enable dialog caching
       Enable( DIALOGCACHE );
      
       // Determine what events to show.
       bUpdateMode = FALSE;
       bMaintenanceMode = FALSE;
    
       // Remove this to disabled update mode.
       if( UPDATEMODE ) then
        bUpdateMode = TRUE;
       endif;
    
       // Remove this to disable maintenance mode.
       if ( MAINTENANCE ) then
        bMaintenanceMode = TRUE;
       endif;
    
       // Show appropriate UI
    
       // TODO: Enable if you want to enable background etc.
       //if ( LoadStringFromStringTable( "TITLE_MAIN", szTitle ) < ISERR_SUCCESS ) then // Load the title string.
       // szTitle = IFX_SETUP_TITLE;
       //endif;
       //SetTitle( szTitle, 24, WHITE );
       //Enable( FULLWINDOWMODE );         
       //Enable( BACKGROUND );
       //SetColor( BACKGROUND, RGB( 0, 128, 128 ) );
    
       if( bUpdateMode ) then
        OnUpdateUIBefore();
       else
        if ( bMaintenanceMode ) then
         OnMaintUIBefore();
        else
         OnFirstUIBefore();
        endif;
       endif;
    
       // Move Data
       OnMoveData();
      
       if( bUpdateMode ) then
        OnUpdateUIAfter();
       else
        if ( bMaintenanceMode ) then
         OnMaintUIAfter();
        else
         OnFirstUIAfter();
        endif;
       endif;
    
       // Disable dialog caching
       Disable(DIALOGCACHE);
    
    end;
    

  • 相关阅读:
    OleDbCommand 的用法
    递归求阶乘
    C#重写窗体的方法
    HDU 5229 ZCC loves strings 博弈
    HDU 5228 ZCC loves straight flush 暴力
    POJ 1330 Nearest Common Ancestors LCA
    HDU 5234 Happy birthday 01背包
    HDU 5233 Gunner II 离散化
    fast-IO
    HDU 5265 pog loves szh II 二分
  • 原文地址:https://www.cnblogs.com/HeroBeast/p/1601633.html
Copyright © 2011-2022 走看看