home *** CD-ROM | disk | FTP | other *** search
/ Programming with VisualAge for Java / IBMVJAVA.ISO / icswinnt / iforls / setup.rul < prev   
Encoding:
Text File  |  1996-10-01  |  16.7 KB  |  555 lines

  1. /*----------------------------------------------------------------------------*\
  2.  *
  3.  *  IIIIIII SSSSSS
  4.  *    II    SS                          InstallShield (R)
  5.  *    II    SSSSSS          (c) 1990-1996, Stirling Technologies, Inc.
  6.  *    II        SS                     All Rights Reserved.
  7.  *  IIIIIII SSSSSS
  8.  *
  9.  *
  10.  *  This code is intended as a supplement to InstallShield documentation
  11.  *  and is provided AS IS.
  12.  *
  13.  *
  14.  *    File Name:  SETUP.RUL
  15.  *
  16.  *  Description:  License Use Runtime Client Installation
  17.  *
  18.  *
  19.  *       Author:  Cristina D'Angelo               Date:   07-96
  20.  *
  21.  *     Comments:
  22.  *
  23.  *
  24.  *
  25.  *
  26. \*----------------------------------------------------------------------------*/
  27.  
  28. declare
  29. #include "sddialog.h"
  30.  
  31. // Constant declarations.
  32. #define SPACE_REQUIRED          7000000          // Disk space in bytes.
  33. #define APP_NAME                "License Use Runtime - Client"
  34. #define PROGRAM_FOLDER_NAME     "License Use Runtime"
  35. #define APPBASE_PATH            "ifor"
  36. #define APPBASE_PATH_WIN32S     "ifor"
  37. #define COMPANY_NAME            "IBM"
  38. #define PRODUCT_NAME            "License Use Runtime"
  39. #define PRODUCT_VERSION         "1.0"
  40. #define PRODUCT_KEY             "i4cfg.exe"
  41. #define DEINSTALL_KEY           "IforCliDeinstKey"
  42. #define UNINSTALL_NAME          "License Use Runtime"
  43.  
  44.  
  45.         // Global variable declarations.
  46.         STRING  svFolder, svDir, szMsg, szFileSet, szTitle, svUninstLogFile;
  47.         STRING  svTarget, szProgram, szParam, szTemp, szAppPath, szMsg1, szMsg2;
  48.         STRING  szKey[255], szValue, svNumValue, szFindMe, szField1, szDir, szDrive;
  49.         STRING  RespFile, RspFilePath, tempstr, StringToStrip;
  50.         BOOL    bSpaceOk, bWinNT, bWin32s, bIsShellExplorer;
  51.         NUMBER  nResult, nvType, nvSize, svLen, Index, GoodIndex;
  52.  
  53.         // Function declarations.
  54.         prototype SetupScreen();
  55.         prototype CheckRequirements();
  56.         prototype CheckReturnPerform(number);
  57.         prototype CreateFolderIcons();
  58.         prototype DoFileTransfer();
  59.         prototype UpdateRegistry();
  60.  
  61. program
  62.  
  63. StartHere:
  64.         Disable( BACKGROUND );
  65.  
  66.         // Set installation info., which is required for registry entries.
  67.         InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
  68.  
  69.         // Set up thr installation screen.
  70.         SetupScreen();
  71.         Enable( DIALOGCACHE );
  72.  
  73.    // Create a Welcome dialog.
  74.    WelcomeDlg:
  75.         Disable( BACKBUTTON );
  76.         Welcome( "", 0 );
  77.         Enable( BACKBUTTON );
  78.  
  79.         // Test target system for proper configuration.
  80.         CheckRequirements();
  81.  
  82.    // Ask user for a destination location for the installation.
  83.    //Only the directory can be chosen. The destination path
  84.    //must be ifor.
  85.    szDir = TARGETDISK;
  86.    GetTargetDirectory:
  87.       bSpaceOk = TRUE;
  88.  
  89.       // Check if the product is already installed retrieving the
  90.       // I4_INSTALL_DRIVE variable
  91.       if (GetEnvVar("I4_INSTALL_DRIVE", szValue)) then
  92.          szMsg = "Setup will install License Use Runtime in the following "+
  93.                  "drive. You may select a different drive by editing the "+
  94.                  "Destination field. "+
  95.                  "Click Cancel to exit the Setup program.";
  96.          szTitle = "Choose Destination Location";
  97.          szField1 = "Destination";
  98.          Disable (BACKBUTTON);
  99.          SdShowDlgEdit1( szTitle, szMsg, szField1, szDir );
  100.          Enable (BACKBUTTON);
  101.          if ((StrLength(szDir) > 2) || (StrLength(szDir) <= 1)) then
  102.            MessageBox( "Only a drive can be entered for the Destination entry.", WARNING);
  103.            goto GetTargetDirectory;
  104.          endif;
  105.          StrSub(szDrive, szDir, 0, 1);
  106.          if ((ExistsDisk(szDrive) = NOTEXISTS)) then
  107.            MessageBox ("The drive entered in the Destination field does not specify a valid drive.", SEVERE);
  108.            goto GetTargetDirectory;
  109.          endif;
  110.          if (GetDiskSpace( szDir ) < SPACE_REQUIRED) then
  111.             szMsg = "There is not enough space available on the disk\n" +
  112.                     "'" + szDir + "' \n" +
  113.                     "Please free up some space or change the target location\n" +
  114.                     "to a different disk";
  115.             MessageBox( szMsg, WARNING );
  116.             bSpaceOk = FALSE;
  117.          endif;
  118.          // If not enough space, ask user to try again.
  119.          if (bSpaceOk = FALSE) goto GetTargetDirectory;
  120.       else
  121.       szDir=szValue;
  122.       szMsg = "Setup program detected a previous installation in the " +
  123.             szDir +" drive. The same drive will used as destination drive " +
  124.             "in order to update the currently installed product or to " +
  125.             "install additional components.";
  126.       MessageBox(szMsg, INFORMATION);
  127.       goto DeInstallInfo;
  128.       endif;
  129.  
  130.  
  131.    // Prepare InstallShield to record deinstallation information.
  132.    DeInstallInfo:
  133.    svTarget = szDir ^ APPBASE_PATH;
  134.  
  135.  
  136.    // Prepare InstallShield to record deinstallation information.
  137.    DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
  138.    RegDBSetItem( REGDB_UNINSTALL_NAME, UNINSTALL_NAME );
  139.  
  140.  
  141.         // Set the App Paths key for the main program.
  142.         szAppPath = svTarget ^ "WIN" ^ "BIN";
  143.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  144.         szProgram = svTarget ^ "WIN\\BIN\\i4cfg.exe";
  145.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  146.  
  147.       RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  148.       szKey = "SOFTWARE\\" + "IBM\\" + PRODUCT_NAME;
  149.       RegDBCreateKeyEx( szKey, "");
  150.       RegDBSetKeyValueEx( szKey, "Version", REGDB_STRING, PRODUCT_VERSION, -1);
  151.  
  152.    SetupFilesToTransfer:
  153.    DoFileTransfer();
  154.  
  155.         nResult = FileSetPerformEz( szFileSet, 0 );
  156.  
  157.         CheckReturnPerform(nResult);
  158.  
  159.         Delay( 1 );
  160.         Disable( STATUSDLG );
  161.  
  162.    // Run the iforreg configuration program
  163.  
  164.    szProgram = svTarget ^ "WIN" ^ "BIN" ^ "IFORREG.EXE";
  165.    LaunchAppAndWait( szProgram, szDir, WAIT);
  166.  
  167.  
  168.    // Update the Registries for IFOR
  169.  
  170.    UpdateRegistry();
  171.  
  172.  
  173.    // Create the folder and icons for the IForLs component
  174.  
  175.    InstallProgramItems:
  176.    CreateFolderIcons();
  177.  
  178.  
  179.  
  180.    // Global variable UNINST stores the name and location of the
  181.    // uninstaller file.
  182.    szProgram = WINDIR ^ "UNINST.EXE" + " -f" + svUninstLogFile;
  183.    AddFolderIcon( svFolder, "unInstall", szProgram,
  184.                   WINDIR, "", 0, "", REPLACE );
  185.    Delay( 1 );
  186.  
  187.  
  188.    // Announce setup complete and offer to read README file.
  189.    FinalInstallProcess:
  190.         SetStatusWindow( 100, "Installation complete." );
  191.  
  192.         if (AskYesNo( "Do you want to view the README file now?", YES ) = YES) then
  193.            LaunchApp( "NOTEPAD.EXE", svTarget ^ "READ.ME" );
  194.            Delay( 8 );
  195.         endif;
  196.  
  197. //        szMsg = "Setup is complete.  You may run the installed program "+
  198. //                "by double-clicking on the program icon.";
  199. //        MessageBox( szMsg, INFORMATION );
  200.  
  201.         MessageBeep( 0 );
  202.         szTitle = "Setup Complete";
  203.  
  204.         szMsg1 = "Setup has finished copying files to your computer." +
  205.                  "You can restart your computer now, or restart it later.\n" +
  206.                  "Select one of the following:";
  207.         szMsg2 = "Click finish to complete setup.";
  208.  
  209.         SdFinishReboot( szTitle,
  210.                         szMsg1,
  211.                         SYS_BOOTMACHINE,
  212.                         szMsg2,
  213.                         0);
  214.  
  215.         exit;
  216.  
  217. #include "sddialog.rul"
  218.  
  219. /*---------------------------------------------------------------------------*\
  220.  *
  221.  * Function:  SetupScreen
  222.  *
  223.  *  Purpose:  This function will set up the screen look.  This includes
  224.  *            colors, fonts, text to be displayed, etc.
  225.  *
  226.  *
  227.  *    Input:
  228.  *
  229.  *  Returns:
  230.  *
  231.  * Comments:
  232. \*---------------------------------------------------------------------------*/
  233. function SetupScreen()
  234.         number nDx, nDy;
  235. begin
  236.         GetExtents( nDx, nDy );
  237.  
  238.         Enable( FULLWINDOWMODE );
  239.         Enable( INDVFILESTATUS );
  240.         Enable( BITMAP256COLORS );
  241.  
  242.         SetTitle( "Installing " + APP_NAME, 24, WHITE );
  243.  
  244.         SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
  245.         SetColor( STATUSBAR, BLUE );     // Bright blue.
  246.         SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
  247.  
  248.         Enable( BACKGROUND );
  249.  
  250.         Delay( 1 );
  251.  
  252. end;
  253.  
  254.  
  255. /*---------------------------------------------------------------------------*\
  256.  *
  257.  * Function:  CheckRequirements
  258.  *
  259.  *  Purpose:  This function will check all minimum requirements for the
  260.  *            application being installed.  If any fail, then the user
  261.  *            is informed and the installation is terminated.
  262.  *
  263.  *
  264.  *    Input:
  265.  *
  266.  *  Returns:
  267.  *
  268.  * Comments:
  269. \*---------------------------------------------------------------------------*/
  270. function CheckRequirements()
  271. number nvDx, nvDy;
  272. number nvResult;
  273. STRING svResult;
  274.  
  275. begin
  276.  
  277.         // Check screen resolution.
  278.         GetExtents( nvDx, nvDy );
  279.         if (nvDy < 480) then
  280.            MessageBox( "This program requires VGA or better resolution.", WARNING );
  281.            exit;
  282.         endif;
  283.  
  284.         // Determine the target system's operating system.
  285.         GetSystemInfo( OS, nvResult, svResult );
  286.         bWinNT  = FALSE;
  287.         bWin32s = FALSE;
  288.         bIsShellExplorer = FALSE;
  289.  
  290.         if (nvResult =  IS_WINDOWSNT) then
  291.            bWinNT = TRUE; // Running Windows NT.
  292.  
  293.            // Check to see if NT is using EXPLORER Shell
  294.            if( QueryShellMgr( svResult ) = 0 ) then
  295.                if( StrCompare( svResult, "EXPLORER.EXE" ) = 0 ) then
  296.                    bIsShellExplorer = TRUE;
  297.                endif;
  298.            endif;
  299.  
  300.         elseif (nvResult =  IS_WIN32S) then
  301.            bWin32s = TRUE; // Running Win32s.
  302.         endif;
  303.  
  304. end;
  305.  
  306.  
  307. /*---------------------------------------------------------------------------*\
  308.  *
  309.  * Function:  CheckReturnPerform(nResult)
  310.  *
  311.  *  Purpose:  This function check the return code of FileSetPerformEz()
  312.  *            function.
  313.  *
  314.  *
  315.  *    Input:  NUMBER nResult
  316.  *
  317. \*---------------------------------------------------------------------------*/
  318.  
  319. function CheckReturnPerform (nResult)
  320.  
  321. begin
  322.         switch (nResult)
  323.  
  324.         case FS_DONE: // Successful completion.
  325.  
  326.         case FS_CREATEDIR: // Create directory error.
  327.              MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
  328.                          "Please check write access to this directory.", SEVERE );
  329.              exit;
  330.  
  331.         default: // Group all other errors under default label.
  332.              NumToStr( szTemp, nResult );
  333.              MessageBox( "General file transfer error."+
  334.                           "Please check your target location and try again."+
  335.                           "\n\n Error Number:"+szTemp +
  336.                           "\n Related File: "+ERRORFILENAME,
  337.                           SEVERE );
  338.              exit;
  339.         endswitch;
  340. end;
  341.  
  342. /*-------------------------------------------------------------------*\
  343.  *
  344.  *
  345.  * function CreateFolderIcons()
  346.  *
  347.  * Description:     Create the product folders and the icons.
  348.  *
  349.  *
  350.  *
  351. \*-------------------------------------------------------------------*/
  352.  
  353. function CreateFolderIcons()
  354.  
  355. begin
  356.     SetStatusWindow( 95, "Creating Program Folder and Icons...." );
  357.  
  358.    svFolder = PROGRAM_FOLDER_NAME;
  359.    svDir = svTarget ^ "WIN" ^ "BIN";
  360.    CreateProgramFolder( svFolder);
  361.    ShowProgramFolder( svFolder, SW_SHOW);
  362.    Delay(1);
  363.  
  364.    AddFolderIcon( svFolder,
  365.                   "Configuration Tool",
  366.                   svDir ^ "I4CONFIG.EXE",
  367.                   svDir,
  368.                   "",
  369.                   0,
  370.                   "",
  371.                   REPLACE);
  372.    Delay(1);
  373.  
  374.    AddFolderIcon( svFolder,
  375.                   "Nodelock Administration Tool",
  376.                   svDir ^ "NAT.EXE",
  377.                   svDir,
  378.                   "",
  379.                   0,
  380.                   "",
  381.                   REPLACE);
  382.    Delay(1);
  383.  
  384.    AddFolderIcon( svFolder,
  385.                   "Using License Use Runtime",
  386.                   svDir ^ "IVIEW.EXE" + " I4BU1MST.INF",
  387.                   svDir,
  388.                   "",
  389.                   0,
  390.                   "",
  391.                   REPLACE);
  392.    Delay(1);
  393.  
  394.    AddFolderIcon( svFolder,
  395.                   "Command Reference",
  396.                   svDir ^ "IVIEW.EXE" + " I4WU1CMD.INF",
  397.                   svDir,
  398.                   "",
  399.                   0,
  400.                   "",
  401.                   REPLACE);
  402.    Delay(1);
  403.  
  404.    AddFolderIcon( svFolder,
  405.                   "Message Reference",
  406.                   svDir ^ "IVIEW.EXE" + " I4DU1MSG.INF",
  407.                   svDir,
  408.                   "",
  409.                   0,
  410.                   "",
  411.                   REPLACE);
  412.    Delay(1);
  413.  
  414. end;
  415.  
  416. /*-------------------------------------------------------------------*\
  417.  *
  418.  *
  419.  * function DoFileTransfer()
  420.  *
  421.  * Description:     Prepare the FileSet and Perform the file transfer
  422.  *
  423.  *
  424.  *
  425. \*-------------------------------------------------------------------*/
  426.  
  427. function DoFileTransfer()
  428.  
  429. begin
  430.  
  431.         szFileSet = "General";
  432.  
  433.         // Define the file set.
  434.         FileSetBeginDefine( szFileSet );
  435.  
  436.         SetStatusWindow( -1, "Copying program files..." );
  437.  
  438.         TARGETDIR = svTarget;
  439.         XCopyFile("READ.ME","READ.ME",COMP_UPDATE_DATE);
  440.  
  441.         TARGETDIR = svTarget ^ "LS" ^ "CONF";
  442.         XCopyFile("I4LS.INI","I4LS.INI",COMP_UPDATE_DATE);
  443.  
  444.         TARGETDIR = svTarget ^ "WIN" ^ "BIN";
  445.         CompressGet("arkbinc.z","*.*",COMP_UPDATE_DATE);
  446.  
  447.         TARGETDIR = svTarget ^ "LS" ^ "MSG" ^ "EN_US";
  448.         CompressGet("arkcatc.z","*.*",COMP_UPDATE_DATE);
  449.  
  450.         TARGETDIR = svTarget ^ "WIN" ^ "BIN";
  451.         CompressGet("arkdoc.z","*.*",COMP_UPDATE_DATE);
  452.  
  453.         TARGETDIR = svTarget ^ "WIN" ^ "BIN";
  454.         XCopyFile("IVIEW.EXE","IVIEW.EXE",COMP_UPDATE_DATE);
  455.  
  456.  
  457.         FileSetEndDefine( szFileSet );
  458.  
  459.         Disable (DIALOGCACHE);
  460.         Enable (STATUSDLG);
  461.  
  462.         StatusUpdate ( ON,90 );
  463.  
  464. end;
  465.  
  466. /*---------------------------------------------------------------------------*\
  467.  *
  468.  * Function:  UpdateRegistry()
  469.  *
  470.  *  Purpose:  This function updates win32 Registry with
  471.  *            iFOR keys
  472.  *
  473.  *
  474.  *    Input:
  475.  *
  476.  *  Returns:
  477.  *
  478.  * Comments:
  479. \*---------------------------------------------------------------------------*/
  480.  
  481. function UpdateRegistry()
  482. begin
  483.  
  484.      RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  485.      Disable( LOGGING );
  486.  
  487.      szKey = "SYSTEM\\" + "CurrentControlSet\\" + "Control\\" +
  488.              "Session Manager\\" + "Environment";
  489.      svNumValue = "";    //initialize svNumValue to null string
  490.      RegDBGetKeyValueEx( szKey, "Path", nvType, svNumValue, nvSize);
  491.  
  492.      szFindMe = svTarget ^ "IFOR" ^ "WIN" ^ "BIN";
  493.      nResult = StrFind( svNumValue,     //check if the key already contains
  494.                         szFindMe);      //the value
  495.  
  496.      if( nResult < 0 ) then
  497.        szValue = svNumValue + ";" + szFindMe;
  498.        RegDBSetKeyValueEx( szKey, "Path", REGDB_STRING_EXPAND, szValue, -1);
  499.      endif;
  500.  
  501.      //Update of NLSPATH Environment variable
  502.  
  503.      svNumValue = "";    //initialize svNumValue to null string
  504.      RegDBGetKeyValueEx( szKey, "NLSPATH", nvType, svNumValue, nvSize);
  505.  
  506.      szFindMe = svTarget ^ "IFOR" ^ "LS" ^ "MSG" ^ "EN_US" ^ "%N";
  507.      nResult = StrFind( svNumValue,     //check if the key already contains
  508.                         szFindMe);      //the value
  509.  
  510.      if( nResult < 0 ) then
  511.        if(svNumValue = "") then
  512.          szValue = szFindMe;
  513.        else
  514.          szValue = svNumValue + ";" + szFindMe;
  515.        endif;
  516.  
  517.        RegDBSetKeyValueEx( szKey, "NLSPATH", REGDB_STRING_EXPAND, szValue, -1);
  518.      endif;
  519.  
  520.  
  521.      //Update of the HELP Environment variable
  522.  
  523.      svNumValue = "";    //initialize svNumValue to null string
  524.      RegDBGetKeyValueEx( szKey, "HELP", nvType, svNumValue, nvSize);
  525.  
  526.      szFindMe = svTarget ^ "IFOR" ^ "WIN" ^ "BIN";
  527.      nResult = StrFind( svNumValue,     //check if the key already contains
  528.                         szFindMe);      //the value
  529.  
  530.      if( nResult < 0 ) then
  531.        if(svNumValue = "") then
  532.          szValue = szFindMe;
  533.        else
  534.          szValue = svNumValue + ";" + szFindMe;
  535.        endif;
  536.        RegDBSetKeyValueEx( szKey, "HELP", REGDB_STRING_EXPAND, szValue, -1);
  537.      endif;
  538.  
  539.      //Create the I4_INSTALL_DRIVE Environment Variable
  540.  
  541.      RegDBSetKeyValueEx( szKey, "I4_INSTALL_DRIVE", REGDB_STRING, szDir, -1);
  542.  
  543.    Enable( LOGGING );
  544.  
  545.  
  546.    EzBatchAddPath("PATH", svTarget ^ "WIN" ^ "BIN;", "", AFTER);
  547.    EzBatchAddPath("NLSPATH", svTarget ^ "LS" ^ "MSG" ^ "EN_US" ^ "%N;", "", AFTER);
  548.    EzBatchAddPath("HELP", svTarget ^ "WIN" ^ "BIN;", "", AFTER);
  549. //     tempstr="I4_INSTALL_DRIVE="+szDir;
  550. //     EzBatchReplace(tempstr);
  551.  
  552.  
  553. end;
  554.  
  555.