Lesson 2: Using InstallShield

As a shortcut for developing setup and uninstall programs, the Professional and Enterprise Editions of Visual C++ include the SDK edition of Stirling Software's InstallShield. (The Learning and Standard Editions don't include this tool, but you can purchase it separately. If you don't have access to this tool, you can still benefit from reading the information in this lesson.)

This lesson introduces the InstallShield toolkit, which enables you to write a script that specifies the steps you want performed during installation. InstallShield then builds a Setup program that installs your product on a user's computer.

With InstallShield, you don't have to write a separate script for uninstallation. InstallShield creates an uninstall program named Uninst that reads a log file created during the setup process. The log file enables Uninst to reverse the steps performed during setup.

InstallShield creates a Setup program for your project that looks and acts much like the Setup program you used to install Visual C++. Microsoft creates Setup programs for many of its products using InstallShield.

An exhaustive description of InstallShield is beyond the scope of this lesson, which is intended only as an introduction to the product. Setup programs today can be surprisingly sophisticated, capable of handling a wide variety of file types, accommodating different operating systems, and handling a bewildering number of potential problems. They must work not only with traditional distribution media such as disks and CD-ROMs, but also across networks and the Internet. InstallShield is not difficult to use, but it offers such a wide array of options designed to address installation issues that gaining familiarity with it can take a while. Furthermore, complete control over the product requires learning its scripting language, InstallScript. As with most programs, practice is the only true teacher.

InstallShield treats your Setup program as a project, the same term applied to normal Visual C++ projects. To avoid confusion, this lesson employs the phrases Setup project or installation project when referring to work done inside InstallShield, and application project when referring to the Visual C++ files that the Setup program deploys in their compressed state.

After this lesson, you will be able to:

  • Configure InstallShield to run as a Visual C++ tool.
  • Step through the InstallShield tutorial.
  • Create a simple Setup program using InstallShield.
Estimated lesson time: 15 minutes

Installing InstallShield

If you selected InstallShield when installing Visual C++, the Visual C++ Tools menu already contains a command for starting the InstallShield Wizard. However, if the command does not appear in the Visual C++ Tools menu and you are not using the Learning or Standard Edition of Visual C++, you should install InstallShield now.

  • To install InstallShield
    1. Place the Visual C++ CD-ROM #1 in your CD-ROM drive.
    2. In Control Panel, start the Add/Remove Programs applet.
    3. Browse to the IShield folder on the CD-ROM and double-click Setup.

    The Setup program installs InstallShield, places a command on the Start\ Programs menu, and adds the InstallShield Wizard command to the Visual C++ Tools menu.

    Running the InstallShield Tutorial

    The InstallShield program provides a good tutorial that demonstrates how to develop a sample Setup program for the familiar Notepad utility. The tutorial walks you through various steps, eventually creating a Setup program that places an icon and command on the Programs menu. When selected, the command invokes Notepad.

    The tutorial shows how InstallShield categorizes your application files into different groups, allowing you to work on different parts of an installation project. Each group contains files with similar characteristics, such as system DLLs, executable files, and Help files.

  • To run the InstallShield tutorial
    1. Click Start, point to Programs, and then click InstallShield for Microsoft Visual C++ 6. InstallShield opens.
    2. On the Help menu, click Getting Started.
    3. In the Help Topics dialog box, expand the list by double-clicking Welcome to InstallShield, Tutorials, and Use the Project Wizard.
    4. Double-click the first entry, Outline: Use the Project Wizard.
    5. Move through the six steps, following the tutorial's instructions.

    After running the completed Setup demonstration, be sure to uninstall it by running the Add/Remove Programs applet, as suggested in the tutorial's last step.

    The preceding example shows how to start InstallShield from the Programs menu, activating the Project Wizard to create a new project or to open an existing project. You can also run InstallShield from inside Visual C++ by clicking the InstallShield Wizard command on the Tools menu. This alternative is convenient for creating a Setup program for an existing Visual C++ application project, because it fills in information that you would otherwise have to enter manually. When you click the InstallShield Wizard command, the wizard appears as shown in Figure 14.3. Select the desired Visual C++ project, click Next, and follow the wizard's remaining instructions.

    click to view at full size.

    Figure 14.3 The InstallShield Wizard, invoked from the Visual C++ Tools menu

    Including and Removing Program Files

    InstallShield scans the application folder and locates all necessary executable files, adding them to the installation project. Figure 14.4 shows how the wizard lists the application's dependency files. In this case, the demo.exe application links dynamically to MFC, so InstallShield adds MFC42.DLL to the Setup project. Because MFC42.DLL in turn uses the C run-time library, the MSVCRT.DLL module is also added to the installation project.

    click to view at full size.

    Figure 14.4 Listing an application's dependency files in the InstallShield Wizard

    If you intend to distribute your application only to sites where you know the files already exist, you might not want to include dependencies such as MFC42.DLL and MSVCRT.DLL in your Setup program. The InstallShield Wizard does not allow you to alter the list, but you can remove the files from the installation project later. After the wizard finishes, it starts InstallShield automatically.

    Creating the Setup.exe Program

    After your installation project compiles and runs correctly, the last step is to build the project. This step enables you to create the Setup.exe program and the associated .cab files to distribute to your users. InstallShield provides the Media Build Wizard to walk you through the steps of creating the Setup program. The following list assumes you have created an installation project and are ready to build a Setup program for it.

  • To create a Setup program
    1. On the InstallShield Build menu, click the Media Build Wizard command.
    2. In the wizard's first step (titled Media Name), type the name of the application project in the Media Name box.
    3. In the second step, choose the type and size of the media you intend to use for your application's deployment. The wizard offers the choice of various disk formats, a CD-ROM, a customizable size, and an option named InstallFromTheWeb that creates a Setup program that is installable over the Internet.
    4. In the third step, choose either Full Build or Quick Build. The Full Build option creates the compressed files required for distribution to users. The Quick Build option is intended only for testing purposes, allowing you to quickly build a Setup project and test it without creating actual compressed files. The disk images created by the Quick Build option contain links to the application files instead of compressed data. The resultant Setup program will run only on the development computer where the application project is stored.
    5. The wizard's third step includes an Advanced button. Click this button to expose a dialog box that allows you to enter various settings and to establish a password for the Setup program. You can also specify the folder to which the Setup files will be written. If you do not specify a folder, the wizard writes the disk image files to C:\MyInstallations\project\Media\project , where project represents the name of the installation project.
    6. Click Next to skip the wizard's fourth step.
    7. In the wizard's fifth step, select the operating systems under which your application can run. InstallShield includes files required for the selected operating systems.
    8. The wizard's sixth and final step is titled Summary. Click Finish to build the Setup program.
    9. InstallShield shows the Building Media dialog box in which an animated display tracks its progress. When the build process is complete, simply click Finish again.

    You now have a folder named Disk Images in your chosen installation project folder. The Disk Images folder contains at least one nested folder named Disk1, which holds the disk image for the first disk of the series. If the Setup requires additional disks, their images are contained in folders Disk2, Disk3, and so forth. The contents of each Disk folder must be copied to disks or other media of the type selected in the Media Build Wizard's second step. If the installation creates more than one Disk folder, each receiving medium must be labeled with the disk number to ensure that users can insert disks in the correct order when prompted to do so.

    As a final test before shipping your application, run the Setup package on a machine other than your development computer. Test the installed application to ensure that all components have been correctly copied and registered, then uninstall the application to ensure that it is correctly removed.

    Lesson Summary

    This lesson introduced the InstallShield program, a tool that creates sophisticated installation programs for Visual C++ projects. InstallShield largely automates the entire process of building a Setup program by scanning for dependencies, generating cabinet files, and creating disk images. InstallShield even provides an uninstaller program named Uninst.

    Through the Media Build Wizard, InstallShield is accessible from inside the Visual C++ environment where it automatically reads information for the cur-rent application project. InstallShield encourages the sorting of project files into distinct categories referred to as file groups, allowing you to specify different characteristics for each group. InstallShield generates a script that governs the installation process, using its own InstallScript language. Complete control over installation is possible by editing the script.



    Microsoft Press - Desktop Applications with Microsoft Visual C++ 6. 0. MCSD Training Kit
    Desktop Applications with Microsoft Visual C++ 6.0 MCSD Training Kit
    ISBN: 0735607958
    EAN: 2147483647
    Year: 1999
    Pages: 95

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net