home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 6 B / CHIP_HITWARE6_B.iso / bonus / MailAlert / mainst.exe / _setup.lib / Setup.rul < prev    next >
Encoding:
Text File  |  1997-02-09  |  11.9 KB  |  350 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.  *    File Name:  SETUP.RUL
  11.  *
  12.  *  Description:  InstallShield Professional Edition
  13.  *                32-bit script.
  14.  *
  15.  *
  16.  *       Author:  Diamond Ridge, Inc.           Date: 2-8-97
  17.  *
  18.  *     Comments:  
  19.  *
  20.  *
  21.  *
  22. \*----------------------------------------------------------------------------*/
  23.  
  24. declare
  25.  
  26. // Constant declarations.
  27. #define SPACE_REQUIRED          4500000          // Disk space in bytes.
  28. #define APP_NAME                "CRADAbase"
  29. #define PROGRAM_FOLDER_NAME     "CRADAbase"
  30. #define APPBASE_PATH            "CRADAbase\\"
  31. #define APPBASE_PATH_WIN32S     "CRADAbase\\"
  32. #define COMPANY_NAME            "Diamond Ridge, Inc."
  33. #define PRODUCT_NAME            "CRADAbase"
  34. #define PRODUCT_VERSION         "1.0"
  35. #define DEINSTALL_KEY           "CRADAbase"
  36. #define UNINSTALL_NAME          "CRADAbase"
  37. #define PRODUCT_KEY             "tucars.exe"
  38.  
  39.         // Global variable declarations.
  40.         STRING  svFolder, svDir, szMsg, szFileSet, szTitle, svUninstLogFile;
  41.         STRING  svTarget, szProgram, szParam, szTemp, szAppPath, svSite, svDUMName;
  42.         BOOL    bSpaceOk, bWinNT, bWin32s, bIsShellExplorer;
  43.         NUMBER  nResult;
  44.     #include "sddialog.h"
  45.  
  46.         // Function declarations.
  47.         prototype SetupScreen();
  48.         prototype CheckRequirements();
  49.  
  50. program
  51.  
  52. StartHere:
  53.         Disable( BACKGROUND );
  54.  
  55.         // Set installation info., which is required for registry entries.
  56.         InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
  57.  
  58.         // Set up thr installation screen.
  59.         SetupScreen();
  60.         Enable( DIALOGCACHE );
  61.  
  62.  
  63.    // Create a Welcome dialog.
  64.    WelcomeDlg:
  65.         Disable( BACKBUTTON );
  66.         Welcome( "", 0 );
  67.         Enable( BACKBUTTON );
  68.  
  69.         // Test target system for proper configuration.
  70.         CheckRequirements();
  71.  
  72.  
  73.    // Ask user for a destination location for the installation.--
  74.    GetTargetDirectory:
  75.         if (bWin32s) then
  76.            svTarget = TARGETDISK ^ APPBASE_PATH_WIN32S;
  77.         else
  78.            svTarget = TARGETDISK ^ APPBASE_PATH;
  79.         endif;
  80.         if ( AskDestPath( "", szMsg,
  81.                           svTarget, 0 ) = 12 ) then
  82.            goto WelcomeDlg;
  83.         endif;
  84.  
  85.         // Perform space check of target drive.
  86.         bSpaceOk = TRUE;
  87.         if (GetDiskSpace( svTarget ) < SPACE_REQUIRED) then
  88.            szMsg = "There is not enough space available on the disk\n" +
  89.                    "'" + svTarget + "' \n" +
  90.                    "Please free up some space or change the target location\n" +
  91.                    "to a different disk";
  92.            MessageBox( szMsg, WARNING );
  93.            bSpaceOk = FALSE;
  94.         endif;
  95.  
  96.          // If not enough space, ask user to try again.
  97.         if (bSpaceOk = FALSE) goto GetTargetDirectory;
  98.  
  99.         // Set the App Paths key for the main program.
  100.         szAppPath = svTarget ^ "PROGRAM";
  101.         RegDBSetItem( REGDB_APPPATH, szAppPath );
  102.         szProgram = svTarget ^ "PROGRAM\\tucars.exe";
  103.         RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
  104.  
  105.    // Ask user for Site Code for database replication.
  106.    GetSite:
  107.     SetDialogTitle(DLG_ASK_TEXT, "Enter Site Code");
  108.     if (AskText("Please enter the Site Code (used for database replication)","",svSite) = 12) then
  109.        goto GetTargetDirectory;
  110.         endif;
  111.     if (svSite = "") goto GetSite;
  112.  
  113.    SetupFilesToTransfer:
  114.         szFileSet = "General";
  115.         TARGETDIR = svTarget;
  116.  
  117.         // Define the file set.
  118.         FileSetBeginDefine( szFileSet );
  119.  
  120.            SetStatusWindow( -1, "Copying program files..." );
  121.            CompressGet( "DATA.Z", "program\\*.*", INCLUDE_SUBDIR );
  122.  
  123.            SetStatusWindow( -1, "Copying TWAIN drivers..." );
  124.        TARGETDIR = WINDIR;
  125.            CompressGet( "DATA.Z", "twain\\*.*", INCLUDE_SUBDIR );
  126.  
  127.            SetStatusWindow( -1, "Copying system files..." );
  128.            TARGETDIR = WINSYSDIR;
  129.            CompressGet( "DATA.Z", "winsys\\*.*", INCLUDE_SUBDIR );
  130.  
  131.         FileSetEndDefine( szFileSet );
  132.  
  133.  
  134.    TransferFiles:
  135.         // Prepare InstallShield to record deinstallation information.
  136.         DeinstallStart( svTarget, svUninstLogFile, DEINSTALL_KEY, 0 );
  137.         RegDBSetItem( REGDB_UNINSTALL_NAME, UNINSTALL_NAME );
  138.  
  139.         // Set up progress indicator and information gauge.
  140.         Disable( DIALOGCACHE );
  141.         Enable( STATUSDLG );
  142.  
  143.         StatusUpdate( ON, 90 );
  144.  
  145.         // Perform the file set.
  146.         SetStatusWindow( 0, "Copying program files..." );
  147.         nResult = FileSetPerformEz( szFileSet, 0 );
  148.  
  149.         switch (nResult)
  150.  
  151.         case FS_DONE: // Successful completion.
  152.  
  153.         case FS_CREATEDIR: // Create directory error.
  154.              MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
  155.                          "Please check write access to this directory.", SEVERE );
  156.              exit;
  157.  
  158.         default: // Group all other errors under default label.
  159.              NumToStr( szTemp, nResult );
  160.              MessageBox( "General file transfer error."+
  161.                           "Please check your target location and try again."+
  162.                           "\n\n Error Number:"+szTemp +
  163.                           "\n Related File: "+ERRORFILENAME,
  164.                           SEVERE );
  165.              exit;
  166.         endswitch;
  167.  
  168.         Delay( 1 );
  169.  
  170. //      Create app subdirectories
  171.         CreateDir(svTarget ^ "Database");
  172.         CreateDir(svTarget ^ "Pictures");
  173.         CreateDir(svTarget ^ "Reports");
  174.         CreateDir(svTarget ^ "Repl");
  175.         CreateDir(svTarget ^ "Repl\\Crada");
  176.         CreateDir(svTarget ^ "Repl\\" + svSite);
  177.  
  178. //      Modify Autoexec.bat
  179.         SetStatusWindow( -1, "Modifying startup files..." );
  180.     BatchFileLoad("");
  181.     BatchDeleteEx("SQLREMOTE",0);
  182.     BatchAdd("SQLREMOTE", svTarget ^ "REPL", "PATH", AFTER);
  183.     BatchFileSave("");
  184.  
  185. //    Modify site-specific info in CRADA.INI
  186.         LongPathToShortPath(svTarget);
  187.     WriteProfString(WINDIR ^ "CRADA.INI", "Account Information", "Site", svSite);
  188.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "Database", svTarget ^ "Database");
  189.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "Logo", svTarget ^ "Crada.bmp");
  190.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "LocalPictures", svTarget ^ "Pictures");
  191.     WriteProfString(WINDIR ^ "CRADA.INI", "Directories", "Reports", svTarget ^ "Reports");
  192.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "TUTransactionDir", "Crada");
  193.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "DealerTransactionFiles", svSite + "\\*.*");
  194.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "LocalDealerTransactionDir", svTarget ^ "Repl" ^ svSite);
  195.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "LocalTUTransactionFiles", svTarget ^ "Repl\\Crada\\*.*");
  196.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "FtpFromTUScript", "c:\\ftptu.txt");
  197.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "IP", "ftp.etu.com");
  198.     WriteProfString(WINDIR ^ "CRADA.INI", "Replication Settings", "FtpToTUScript", "c:\\ftp2tu.txt");
  199.     WriteProfString(WINDIR ^ "CRADA.INI", "TUADS Car Scheduling", "Program", svTarget ^ svDUMName);
  200.  
  201.    // Create program folders and icons.
  202.    InstallProgramItems:
  203.         SetStatusWindow( 95, "Creating Program Folder and Icons...." );
  204.  
  205.         AppCommand( PROGMAN, CMD_RESTORE );
  206.         svFolder = PROGRAM_FOLDER_NAME;
  207.         CreateProgramFolder( svFolder );
  208.         ShowProgramFolder( svFolder, 0 );
  209.         LongPathToShortPath( svTarget );
  210.         Delay(1);
  211.  
  212.         szProgram = svTarget ^ "TUCARS.EXE";
  213.            AddFolderIcon( svFolder, APP_NAME, szProgram,
  214.                           svTarget,
  215.                           "", 0, "", REPLACE );
  216.            Delay( 1 );
  217.  
  218.            szProgram = svTarget ^ svDUMName;
  219.            AddFolderIcon( svFolder, "CRADAbase Update Module", szProgram,
  220.                           svTarget,
  221.                           "", 0, "", REPLACE );
  222.            Delay( 1 );
  223.  
  224.            szProgram = svTarget ^ "TUSEND.EXE";
  225.            AddFolderIcon( svFolder, "CRADAbase AutoSender", szProgram,
  226.                           svTarget,
  227.                           "", 0, "", REPLACE );
  228.            Delay( 1 );
  229.  
  230.            // Global variable UNINST stores the name and location of the
  231.            // uninstaller file.
  232.            szProgram = UNINST;
  233.            LongPathToShortPath( szProgram );
  234.            LongPathToShortPath( svUninstLogFile );
  235.            szProgram = szProgram + " -f" + svUninstLogFile;
  236.            AddFolderIcon( svFolder, "UnInstall CRADAbase", szProgram,
  237.                           WINDIR, "", 0, "", REPLACE );
  238.  
  239.         Disable( STATUSDLG );
  240.         Delay( 1 );
  241.  
  242.    // Announce setup complete and offer to read README file.e
  243.    FinalInstallProcess:
  244.         SetStatusWindow( 100, "Installation complete." );
  245.  
  246.     SdFinishReboot ("", "", SYS_BOOTMACHINE, "", 0);
  247.  
  248. //        szMsg = "Setup is complete.  You may run the installed program "+
  249. //                "by double-clicking on the program icon.";
  250. //        MessageBox( szMsg, INFORMATION );
  251.  
  252.         exit;
  253.  
  254.  
  255. /*---------------------------------------------------------------------------*\
  256.  *
  257.  * Function:  SetupScreen
  258.  *
  259.  *  Purpose:  This function will set up the screen look.  This includes
  260.  *            colors, fonts, text to be displayed, etc.
  261.  *
  262.  *
  263.  *    Input:
  264.  *
  265.  *  Returns:
  266.  *
  267.  * Comments:
  268. \*---------------------------------------------------------------------------*/
  269. function SetupScreen()
  270.         number nDx, nDy;
  271. begin
  272.         GetExtents( nDx, nDy );
  273.  
  274.         Enable( FULLWINDOWMODE );
  275.         Enable( INDVFILESTATUS );
  276.         Enable( BITMAP256COLORS );
  277.  
  278.         SetTitle( "Installing " + APP_NAME, 24, WHITE );
  279.  
  280.         SetColor( BACKGROUND, BK_BLUE ); // Dark blue.
  281.         SetColor( STATUSBAR, BLUE );     // Bright blue.
  282.         SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
  283.  
  284.         Enable( BACKGROUND );
  285.  
  286.         Delay( 1 );
  287.  
  288. end;
  289.  
  290.  
  291. /*---------------------------------------------------------------------------*\
  292.  *
  293.  * Function:  CheckRequirements
  294.  *
  295.  *  Purpose:  This function will check all minimum requirements for the
  296.  *            application being installed.  If any fail, then the user
  297.  *            is informed and the installation is terminated.
  298.  *
  299.  *
  300.  *    Input:
  301.  *
  302.  *  Returns:
  303.  *
  304.  * Comments:
  305. \*---------------------------------------------------------------------------*/
  306. function CheckRequirements()
  307. number nvDx, nvDy;
  308. number nvResult;
  309. STRING svResult;
  310.  
  311. begin
  312.  
  313.         // Check screen resolution.
  314.         GetExtents( nvDx, nvDy );
  315.         if (nvDy < 480) then
  316.            MessageBox( "This program requires VGA or better resolution.", WARNING );
  317.            exit;
  318.         endif;
  319.  
  320.         // Determine the target system's operating system.
  321.         GetSystemInfo( OS, nvResult, svResult );
  322.         bWinNT  = FALSE;
  323.         bWin32s = FALSE;
  324.         bIsShellExplorer = FALSE;
  325.  
  326.     // Set filename of DUM for Win 3.x vs. Win 95/NT
  327.     if (nvResult = IS_WINDOWS) then
  328.            svDUMName = "DUM.EXE";
  329.      else
  330.        svDUMName = "DUM32.EXE";
  331.     endif;
  332.         
  333.         if (nvResult =  IS_WINDOWSNT) then
  334.            bWinNT = TRUE; // Running Windows NT.
  335.  
  336.            // Check to see if NT is using EXPLORER Shell
  337.            if( QueryShellMgr( svResult ) = 0 ) then
  338.                if( StrCompare( svResult, "EXPLORER.EXE" ) = 0 ) then
  339.                    bIsShellExplorer = TRUE;
  340.                endif;
  341.            endif;
  342.  
  343.         elseif (nvResult =  IS_WIN32S) then
  344.            bWin32s = TRUE; // Running Win32s.
  345.         endif;
  346.  
  347. end;
  348.  
  349. #include "sddialog.rul"
  350.