home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------*\
- *
- * IIIIIII SSSSSS
- * II SS InstallSHIELD (R)
- * II SSSSSS (c) 1990-1995, Stirling Technologies, Inc.
- * II SS All Rights Reserved.
- * IIIIIII SSSSSS
- *
- *
- * This source code is intended as a supplement to Stirling Technologies,
- * Inc., product documentation. Refer to your Stirling Technologies, Inc.,
- * product documentation for more detailed information.
- *
- *
- * File Name: SETUP.RUL
- *
- * Description: InstallSHIELD SDK Edition MFC Sample script.
- *
- *
- *
- *
- * Author: Stirling Technologies, Inc. Date: 2-4-95
- *
- * Comments: This sample script installs a simple MFC application
- * to a Windows 95 or Windows NT platform. The installation
- * includes application program files, sample files,
- * and help files. For information on using this script,
- * see the file README.TXT.
- * With minor modifications, this script can be
- * adapted to create new, customized installations.
- *
- *
- *
- \*----------------------------------------------------------------------------*/
-
-
-
- // Size of components.
- #define SIZE_REQ_SAMPLES 12000
- #define SIZE_REQ_HELP 32000
- #define SIZE_REQ_PROGRAM 1300000
-
- #define APP_NAME "Drawing Client"
- #define PROGRAM_GROUP_NAME "YourCompany Applications"
- #define APPBASE_PATH "YourCompany\\DrawCli\\"
- #define COMPANY_NAME "YourCompany"
- #define PRODUCT_NAME "Drawing Client"
- #define PRODUCT_VERSION "2.0"
- #define PRODUCT_KEY "drawcli.exe"
- #define UNINSTALL_KEY "DrawCliV3"
- #define APPBASE_DIR95 "Program Files"
- #define BASE_REGISTRYNT "Software\\Microsoft\\Windows NT\\CurrentVersion\\App Paths\\"
- #define BASE_REGISTRY95 "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"
-
- #define STR_COMPLETE95 "by selecting the program icon in the Programs menu.\n\n"
- #define STR_COMPLETENT "by selecting the program icon in the program group.\n\n"
-
- declare
-
- // Global variable declarations.
- STRING svGrp, szMsg, szFileSet, szTitle, szAppPath, szAppSharedDir;
- STRING szProgram, szTemp, svUninstLogFile, szRegKey;
- STRING svMainDirectory[ _MAX_STRING ];
- BOOL bSpaceOk, bReshowSetupType;
- NUMBER nResult, nStatusId, nType;
-
- BOOL bIncludeProgram, bIncludeSamples, bIncludeHelp;
- BOOL bWinNT;
-
- // Function declarations.
- prototype SetupScreen();
- prototype CheckRequirements();
- prototype CheckSpaceRequirements( number, number, number, string );
- prototype CreateRegDBEntries();
-
- program
-
- StartHere:
- Disable( BACKGROUND );
-
- // Set up the installation screen.
- SetupScreen();
-
- // Set installation info., which is required for registry entries.
- InstallationInfo( COMPANY_NAME, PRODUCT_NAME, PRODUCT_VERSION, PRODUCT_KEY );
-
- // Create a Welcome dialog.
- WelcomeDlg:
- Disable( BACKBUTTON );
- Welcome( "Welcome", 0 );
- Enable( BACKBUTTON );
-
- // Test target system proper configuration.
- CheckRequirements();
-
- // Ask user for a destination location for the installation.
- GetTargetDirectory:
-
- svMainDirectory = TARGETDISK ^ APPBASE_DIR95 ^ APPBASE_PATH;
-
- szMsg = "Please enter the destination path\n"+
- "To accept the default, select > (Next)";
- if ( AskDestPath( "Choose Destination Location", szMsg,
- svMainDirectory, 0 ) = BACK ) then
- goto WelcomeDlg;
- endif;
-
- szAppSharedDir = svMainDirectory ^ "System";
-
- nType = TYPICAL;
- DetermineUserSelection:
-
- nType = SetupType( "Selection of Installation Type", "", svMainDirectory, nType, 0 );
- if ( nType = BACK ) then goto GetTargetDirectory; endif;
-
- bReshowSetupType = FALSE;
-
- switch (nType)
- case TYPICAL:
- bIncludeSamples = TRUE;
- bIncludeProgram = TRUE;
- bIncludeHelp = TRUE;
- case COMPACT:
- bIncludeProgram = TRUE;
- case CUSTOM:
- SetDialogTitle( DLG_ASK_OPTIONS, "Select Components" );
- bIncludeSamples = TRUE;
- bIncludeProgram = TRUE;
- bIncludeHelp = TRUE;
- szMsg = "Select the components that you wish to install.\n"+
- "If the check box is unchecked, that component will not be "+
- "installed. Click Next to continue with the installation.";
-
- nResult = AskOptions( NONEXCLUSIVE, szMsg,
- "Application Program Files", bIncludeProgram,
- "Sample Files", bIncludeSamples,
- "On-Line Help Files", bIncludeHelp );
-
- if ( nResult = BACK ) then goto DetermineUserSelection; endif;
-
- // Handle user clicking Cancel button.
- if (nResult = CANCEL) then
- if (AskYesNo( "Are you sure you would like to exit setup?", NO ) = YES) then
- abort;
- else
- bReshowSetupType = TRUE;
- endif;
- endif;
- endswitch;
-
- if (bReshowSetupType = TRUE) then goto DetermineUserSelection; endif;
-
- // Check to see if target system meets space requirements.
- bSpaceOk = CheckSpaceRequirements( bIncludeSamples,
- bIncludeProgram,
- bIncludeHelp,
- svMainDirectory );
-
- // Ask user to try again if not enough space available.
- if (bSpaceOk = FALSE) then goto DetermineUserSelection; endif;
-
- FolderSelection:
- if ( bWinNT ) then
- svGrp = PROGRAM_GROUP_NAME;
-
- // Allow user to modify folder name.
- if ( SelectFolder( "Folder Selection", svGrp, svGrp ) = BACK ) then
- goto DetermineUserSelection;
- endif;
- endif;
-
- FileTransferSetup:
-
- // Prepare InstallSHIELD to record deinstallation information.
- DeinstallStart( svMainDirectory, svUninstLogFile, UNINSTALL_KEY, 0 );
- RegDBSetItem( REGDB_UNINSTALL_NAME, APP_NAME );
-
- // Set registry App Paths key information for the main application.
- szAppPath = svMainDirectory ^ "PROGRAM" + ";" + szAppSharedDir;
- RegDBSetItem( REGDB_APPPATH, szAppPath );
- szProgram = svMainDirectory ^ "PROGRAM\\drawcli.exe";
- RegDBSetItem( REGDB_APPPATH_DEFAULT, szProgram );
-
- // Define the "General" file set.
- szFileSet = "General";
- TARGETDIR = svMainDirectory;
-
- FileSetBeginDefine( szFileSet );
-
- SetStatusWindow( -1, "Copying program files..." );
-
- // Always copy README & related files, located at
- // the root level in the DATA.Z library file.
- CompressGet( "data.z", "*.*", COMP_NORMAL );
-
- if (bIncludeProgram) then
- TARGETDIR = svMainDirectory ^ "PROGRAM";
- CompressGet( "data.z", "program\\*.*", INCLUDE_SUBDIR );
- if ( bWinNT ) then
- TARGETDIR = TARGETDISK ^ "\\WINNT35\\SYSTEM32";
- else
- TARGETDIR = TARGETDISK ^ "\\WINDOWS\\SYSTEM";
- endif;
- CompressGet( "data.z", "shared\\*.*",
- SHAREDFILE | COMP_UPDATE_VERSION );
- // CompressGet( "data.z", "shared\\*.*", COMP_NORMAL );
- // TARGETDIR = szAppSharedDir;
- // CompressGet( "data.z", "shared\\*.*", SHAREDFILE | COMP_NORMAL );
- endif;
-
- if (bIncludeSamples) then
- TARGETDIR = svMainDirectory ^ "SAMPLES";
- CompressGet( "data.z", "samples\\*.*", INCLUDE_SUBDIR );
- endif;
-
- if (bIncludeHelp) then
- TARGETDIR = svMainDirectory ^ "HELP";
- CompressGet( "data.z", "help\\*.*", INCLUDE_SUBDIR );
- endif;
-
- FileSetEndDefine( szFileSet );
-
- DoFileTransfer:
- // Set up progress indicator and information gauge.
- Enable( STATUSDLG );
- StatusUpdate( ON, 50 );
-
- // Perform the file set.
- nResult = FileSetPerformEz( szFileSet, 0 );
-
- switch (nResult)
-
- case FS_DONE: // Successful completion.
-
- case FS_CREATEDIR: // Create directory error.
- MessageBox( "Unable to create a directory under " + TARGETDIR + "."+
- "Please check write access to this directory.", SEVERE );
- abort;
-
- default: // Group all other errors under default label.
- NumToStr( szTemp, nResult );
- MessageBox( "General file transfer error."+
- "Please check your target location and try again."+
- "\n\n Error Number:"+szTemp, SEVERE );
-
- abort;
- endswitch;
-
- SetRegistryEntries:
-
- CreateRegDBEntries( );
-
- Delay(2);
- Disable( FEEDBACK_FULL );
- Disable( STATUSDLG );
-
- // Create program groups (folders) and icons.
-
- CreateFolderIcons:
- SetStatusWindow( 99, "Installing program icon to the Start Menu...." );
-
- if ( bWinNT ) then
- CreateProgramFolder( svGrp );
- ShowProgramFolder( svGrp, SW_SHOW );
- LongPathToShortPath( svMainDirectory );
- Delay(1);
- endif;
-
- TARGETDIR = svMainDirectory;
-
- if (bIncludeProgram) then
- szProgram = TARGETDIR ^ "PROGRAM\\DRAWCLI.EXE";
- if ( bWinNT ) then
- AddFolderIcon( svGrp, APP_NAME, szProgram,
- TARGETDIR ^ "PROGRAM",
- "", 0, "", REPLACE );
- else
- LongPathToQuote( szProgram, TRUE );
- AddFolderIcon( "", APP_NAME, szProgram,
- TARGETDIR ^ "PROGRAM",
- "", 0, "", REPLACE );
- endif;
- Delay( 1 );
- endif;
-
- if ( bWinNT ) then
- if (bIncludeSamples) then
- szProgram = TARGETDIR ^ "PROGRAM\\DRAWCLI.EXE ";
- AddFolderIcon( svGrp, "Example1",
- szProgram + TARGETDIR ^ "SAMPLES\\DRAWCLI1.DRW",
- TARGETDIR ^ "SAMPLES",
- szProgram, 1, "", REPLACE );
- Delay( 1 );
- endif;
-
- if (bIncludeSamples) then
- AddFolderIcon( svGrp, "Example2",
- szProgram + TARGETDIR ^ "SAMPLES\\HMM.DRW",
- TARGETDIR ^ "SAMPLES",
- szProgram, 1, "", REPLACE );
- Delay( 1 );
- endif;
-
- AddFolderIcon( svGrp, "ReadmeFile",
- "NOTEPAD.EXE " + TARGETDIR ^ "README.TXT",
- TARGETDIR,
- "", 0, "", REPLACE );
- Delay( 1 );
-
- szProgram = WINDIR ^ "UNINST.EXE";
- LongPathToShortPath( szProgram );
- LongPathToShortPath( svUninstLogFile );
- AddFolderIcon( svGrp, "Uninstaller",
- szProgram + " -f" + svUninstLogFile,
- WINDIR,
- "", 0, "", REPLACE );
- Delay( 1 );
- endif;
-
- // Announce setup complete.
-
- SetStatusWindow( 100, "Installation complete." );
-
- // If shared files could not be installed, then users must restart system.
- if (BATCH_INSTALL = TRUE) then
- szMsg = "Some files could not be installed because they are "+
- "currently in use by other programs in the system. "+
- "To allow for proper operation of the new program you should restart"+
- "your system at this time.";
- if (RebootDialog( "Restart Windows", szMsg, SYS_BOOTMACHINE ) = 0) then
- // Set up shared files to be installed after system is next rebooted.
- CommitSharedFiles(0);
- endif;
- else
-
- szMsg = "Setup is complete. You may run the installed program ";
- if ( bWinNT ) then
- szMsg = szMsg + STR_COMPLETENT;
- else
- szMsg = szMsg + STR_COMPLETE95;
- endif;
-
- MessageBeep( 0 );
- MessageBox( szMsg, INFORMATION );
- endif;
-
- exit;
-
-
- /*---------------------------------------------------------------------------*\
- *
- * Function: SetupScreen
- *
- * Purpose: This function will set up the screen look. This includes
- * colors, fonts, text to be displayed, etc.
- *
- *
- * Input:
- *
- * Returns:
- *
- * Comments:
- \*---------------------------------------------------------------------------*/
-
- function SetupScreen()
- begin
-
- Enable( DEFWINDOWMODE );
- Enable( INDVFILESTATUS );
-
- SetTitle( APP_NAME + " Setup", 36, WHITE );
-
- SetTitle( "Setup", 0, BACKGROUNDCAPTION ); // Caption bar text.
-
- Enable( BACKGROUND );
-
- end;
-
-
- /*---------------------------------------------------------------------------*\
- *
- * Function: CheckRequirements
- *
- * Purpose: This function will check all minimum requirements for the
- * application being installed. If any fail, then the user
- * is informed and the installation is terminated.
- *
- *
- * Input:
- *
- * Returns:
- *
- * Comments:
- \*---------------------------------------------------------------------------*/
-
- function CheckRequirements()
- number nvDx, nvDy;
- number nvResult;
- STRING szResult;
- begin
-
- // Determine if target system uses NT or Windows 95.
- GetSystemInfo( WINMAJOR, nvResult, szResult );
- bWinNT = TRUE;
- if (nvResult = 4) then
- bWinNT = FALSE; // Running Windows 95.
- endif;
-
- // Check screen resolution.
- GetExtents( nvDx, nvDy );
- if (nvDy < 480) then
- MessageBox( "This program requires VGA or better resolution.", WARNING );
- exit;
- endif;
-
- end;
-
- /*---------------------------------------------------------------------------*\
- *
- * Function: CheckSpaceRequirements
- *
- * Purpose: This function will check space requirements based on the
- * elements being installed.
- *
- * Input:
- *
- * Returns:
- *
- * Comments:
- \*---------------------------------------------------------------------------*/
-
- function CheckSpaceRequirements( bIncludeSamples,
- bIncludeProgram,
- bIncludeHelp,
- szDir )
- number nSizeRequired;
- begin
-
- nSizeRequired = 0;
-
- // Determine total size.
- if (bIncludeSamples) then
- nSizeRequired = nSizeRequired + SIZE_REQ_SAMPLES;
- endif;
-
- if (bIncludeHelp) then
- nSizeRequired = nSizeRequired + SIZE_REQ_HELP;
- endif;
-
- if (bIncludeProgram) then
- nSizeRequired = nSizeRequired + SIZE_REQ_PROGRAM;
- endif;
-
- // Check space on target drive.
- bSpaceOk = TRUE;
- if (GetDiskSpace( szDir ) < nSizeRequired) then
- szMsg = "There is not enough space available on the disk\n" +
- "'" + svMainDirectory + "' \n" +
- "Please free up some space or change the target location\n" +
- "to a different disk";
- MessageBeep(0);
- MessageBox( szMsg, WARNING );
- bSpaceOk = FALSE;
- endif;
-
- return bSpaceOk;
- end;
-
-
- /*---------------------------------------------------------------------------*\
- *
- * Function: CreateRegDBEntries
- *
- * Purpose: This function will create necessary keys and values for
- * the sample program.
- *
- * Input:
- *
- * Returns:
- *
- * Comments:
- \*---------------------------------------------------------------------------*/
-
- function CreateRegDBEntries()
- string szKey[255], szValue, szDemo, szProgram;
- begin
-
- RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
-
- // Create PRODUCT_KEY key.
- szKey = "SOFTWARE\\" + COMPANY_NAME + "\\" + PRODUCT_NAME + "\\" +
- PRODUCT_VERSION + "\\" + "DRAWCLI";
- RegDBCreateKeyEx( szKey, "" );
-
- // The following keys are duplicates of ones that the MFC library
- // will create. They're included so that they'll be registered
- // in the log used by InstallSHIELD's uninstall program, causing
- // them to be removed upon uninstall.
-
- // create key used by CWinApp::SetRegisterKey
- RegDBSetDefaultRoot( HKEY_CURRENT_USER );
- RegDBCreateKeyEx( "Software\\" + COMPANY_NAME, "" );
-
- // create keys used by CWinApp::EnableShellFileTypes
- RegDBSetDefaultRoot( HKEY_CLASSES_ROOT );
- RegDBCreateKeyEx( ".DRW", "" );
- RegDBCreateKeyEx( "DrawCl.Document", "" );
-
- // register filetype icon
- RegDBCreateKeyEx( "DrawCl.Document\\DefaultIcon", "" );
- RegDBSetKeyValueEx( "DrawCl.Document\\DefaultIcon",
- "", REGDB_STRING, APPBASE_DIR95 + "\\" +
- APPBASE_PATH + "\\PROGRAM\\" + PRODUCT_KEY + ",1", -1 );
- end;
-
-