Installshield代码(DEMO)

 #include "ifx.h"
#include "isrt.h"
    
// string defines
number  nResult,nSetupType;
string  szODBCDir;
string  szUninstall;

installation declarations ///

// ----- DLL function prototypes -----

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

    // your DLL function prototypes


// ---- script function prototypes -----


    // your script function prototypes

    // your global variables

//
//
//  FUNCTION:   OnBegin
//
//  EVENT:      Begin event is always sent as the first event during installation.
//
//
function OnBegin()
    STRING szKey, szNumName, svNumValue;
    NUMBER nvType, nvSize;
    STRING svResult;
    NUMBER nResult;
begin  
    szUninstall="";
    //szKey = "SOFTWARE//ODBC//ODBC.INI//GstFire";
    //szNumName  = "DBQ";
      //RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    // Retrieve key value information.
    //szODBCDir  =  "";         
   // if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue,nvSize) >= 0) then  
    //  if(nvSize>28) then
    //        StrSub (szODBCDir, svNumValue, 0, nvSize-28);  
            //INSTALLDIR = szODBCDir;
     //  endif;
   // endif;
   
end;

//
//                                                                           
//  FUNCTION:   OnFirstUIBefore                                            
//                                                                           
//  EVENT:      FirstUIBefore event is sent when installation is run for the first
//              time on given machine. In the handler installation usually displays
//              UI allowing end user to specify installation parameters. After this
//              function returns, FeatureTransferData is called to perform file
//              transfer.
//                                                                           
///
function OnFirstUIBefore()
    number  nResult;
    string  szTitle, szMsg;
    string  szLicenseFile, szQuestion;
    string  szName, szCompany;
    string  szFile;
    string  szTargetPath;
    string  szDir;
    string  szfolder;
    string  szFeatures, szTargetdir;
    number  nLevel;
    LIST    listStartCopy;
    LIST    list;
    number  nvSize;
    number  nUser;
begin    
    // TO DO: if you want to enable background, window title, and caption bar title                                                                     
    // SetTitle( @PRODUCT_NAME, 24, WHITE );                                        
    // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );                        
    // Enable( FULLWINDOWMODE );                           
    // Enable( BACKGROUND );                              
    // SetColor(BACKGROUND,RGB (0, 128, 128));                       
    
    SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
    
    nSetupType = TYPICAL;    
    szDir = INSTALLDIR;
    szName    = "";
    szCompany = "";

Dlg_Start:
    // beginning of dialogs label

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

Dlg_SdLicense:
    szLicenseFile = SUPPORTDIR ^ "HWVDSLicense.txt";
    szTitle    = "";
    szMsg      = "";
    szQuestion = "";
    nResult    = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
    if (nResult = BACK) goto Dlg_SdWelcome;  
    
Dlg_SdShowInfoList:
    szFile = SUPPORTDIR ^ "HWVDSInfolist.txt";
    list = ListCreate( STRINGLIST );
    ListReadFromFile( list, szFile );
    szTitle  = "";
    szMsg    = "";
    nResult  = SdShowInfoList( szTitle, szMsg, list );    
    ListDestroy( list );
    if (nResult = BACK) goto Dlg_SdLicense;    
    
Dlg_SdCustomerInformation:
    szMsg   = "";
    szTitle = "";    
    nResult = SdCustomerInformation( szTitle, szName, szCompany, nUser );
    if (nResult = BACK) goto Dlg_SdLicense;
    //if(szODBCDir != "") goto Dlg_SetupType;
    
Dlg_SdAskDestPath:
    szTitle = "";
    szMsg   = "";
    nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
    INSTALLDIR = szDir;
    if (nResult = BACK) goto Dlg_SdCustomerInformation;     
        
Dlg_SetupType:   
    szTitle    = "";
    szMsg      = "";
    nResult = SetupType ( szTitle , szMsg , "" , nSetupType , 0 );
    
    if (nResult = BACK) then
         if(szODBCDir = "") then
            goto Dlg_SdAskDestPath;
         else
             goto Dlg_SdCustomerInformation;
         endif;
    else
        nSetupType = nResult;
        if (nSetupType != CUSTOM) then
           szTargetPath = INSTALLDIR;
           nvSize = 0;
           FeatureCompareSizeRequired(MEDIA,szTargetPath,nvSize);
           if (nvSize != 0) then      
                   MessageBox( szSdStr_NotEnoughSpace, WARNING );
               goto Dlg_SetupType;
            endif;
        endif;   
    endif;

Dlg_SdFeatureTree:
    if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType;
    szTitle    = "";
    szMsg      = "";
    szTargetdir = INSTALLDIR;
    szFeatures = "";
    nLevel = 2;
    if (nSetupType = CUSTOM) then
            nResult = SdFeatureTree(szTitle, szMsg, szTargetdir, szFeatures, nLevel);
            if (nResult = BACK) goto Dlg_SetupType;  
    endif;  
    
Dlg_SdSelectFolder:
    szfolder = SHELL_OBJECT_FOLDER;
    szTitle    = "";
    szMsg      = "";
    nResult    = SdSelectFolder( szTitle, szMsg, szfolder );
    SHELL_OBJECT_FOLDER = szfolder;
    if (nResult = BACK) goto Dlg_SdFeatureTree;

Dlg_SdStartCopy:
    szTitle = "";
    szMsg   = "";
    listStartCopy = ListCreate( STRINGLIST );
    //The following is an example of how to add a string(szName) to a list(listStartCopy).
    //eg. ListAddString(listStartCopy,szName,AFTER);
    ListAddString(listStartCopy,"User Name:                       " + szName,AFTER);  
    ListAddString(listStartCopy,"Company Name:                " + szCompany,AFTER);   
    if (nUser=1) then
        ListAddString(listStartCopy,"Install this application For: Any one who use this computer(All Users)" ,AFTER);   
    else
        ListAddString(listStartCopy,"Install this application For: Only for me " ,AFTER);   
    endif;  
    if (nSetupType=301) then  
          ListAddString(listStartCopy,"Setup Type:                      Typical" ,AFTER);   
    elseif (nSetupType=302) then
        ListAddString(listStartCopy,"Setup Type:                      Compact",AFTER);   
    else
        ListAddString(listStartCopy,"Setup Type:                      Costom",AFTER);   
    endif;
    ListAddString(listStartCopy,"Destination Folder:            " + szfolder,AFTER);   
    ListAddString(listStartCopy,"Destination Direction Folder:       " + szTargetdir,AFTER);   
    
    nResult = SdStartCopy( szTitle, szMsg, listStartCopy );    
    ListDestroy(listStartCopy);
    if (nResult = BACK) goto Dlg_SdFeatureTree;

    Enable(STATUSEX);

    return 0;
end;

///
//
//  FUNCTION:   OnMaintUIBefore
//
//  EVENT:      MaintUIBefore event is sent when end user runs installation that
//              has already been installed on the machine. Usually this happens
//              through Add/Remove Programs applet. In the handler, installation
//              usually displays UI allowing end user to modify existing installation
//              or uninstall application. After this function returns,
//              FeatureTransferData is called to perform file transfer.
//
///
function OnMaintUIBefore()
    NUMBER nResult, nType;
    STRING szTitle, szMsg, svDir, svResult, szCaption;
begin
    // TO DO: if you want to enable background, window title, and caption bar title                                   
    // SetTitle( @PRODUCT_NAME, 24, WHITE );                    
    // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );              
    // SetColor(BACKGROUND,RGB (0, 128, 128));                    
    // Enable( FULLWINDOWMODE );                        
    // Enable( BACKGROUND );                            
    szUninstall="Uninstall";
Dlg_Start:
    Disable(BACKBUTTON);
    nType = SdWelcomeMaint(szTitle, szMsg, MODIFY);
    Enable(BACKBUTTON);

    if (nType = REMOVEALL) then
        svResult = SdLoadString(IFX_MAINTUI_MSG);
        szCaption = SdLoadString(IFX_ONMAINTUI_CAPTION);
        nResult = SprintfBox(MB_OKCANCEL,szCaption,"%s",svResult);
        if (nResult = IDCANCEL) goto Dlg_Start;
    endif;

    nResult = NEXT;

Dlg_SdFeatureTree:
    if (nType = MODIFY) then
        szTitle = "";
        szMsg = "";
        nResult = SdFeatureTree(szTitle, szMsg, TARGETDIR, "", 2);
        if (nResult = BACK) goto Dlg_Start;
    endif;

    switch(nType)
        case REMOVEALL: ComponentRemoveAll();
        case REPAIR:    ComponentReinstall();
    endswitch;
    
    Enable(STATUSEX);
end;
///
//
//  FUNCTION:   OnEnd
//
//  EVENT:      End event is the last event. It is not sent if the installation
//              has been aborted. In this case Abort event is sent
//
///

function OnEnd()
    STRING svResult;
    NUMBER nResult;
begin  
    if(szUninstall=="") then
         /* if (FindFile (INSTALLDIR^"Driver//Video Card//", "setup.exe", svResult) = 0) then
            svResult="Are you need to install the video card driver?";
            nResult = SprintfBox(MB_YESNO,"INFORMATION","%s",svResult);  
            if (nResult = IDYES) then   
                if (LaunchApp (INSTALLDIR^"Driver//Video Card//setup.exe", "") < 0)   then
                    MessageBox ("Install video card driver failed! ", SEVERE);
                endif;
            endif;
          endif;
          */    
          if (FindFile (INSTALLDIR^"Driver//IO Card//", "Dog Driver.exe", svResult) = 0) then
              if (LaunchAppAndWait(INSTALLDIR^"Driver//IO Card//Dog Driver.exe", "",LAAW_OPTION_WAIT) < 0)   then
                    MessageBox ("Install dog driver failed! ", SEVERE);
              endif;
          endif;  
          if (FindFile (INSTALLDIR^"Driver//IO Card//", "PCI1762.exe", svResult) = 0) then
            svResult="Are you need to install the I/O card driver?";
            nResult = SprintfBox(MB_YESNO,"INFORMATION","%s",svResult);  
            if (nResult = IDYES) then   
                if (LaunchAppAndWait(INSTALLDIR^"Driver//IO Card//PCI1762.exe", "",LAAW_OPTION_WAIT) < 0)   then
                    MessageBox ("Install I/O card driver failed! ", SEVERE);
                endif;
            endif;
          endif;     
       endif;
       
end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值