Visual Basic Concepts
Using the Package and Deployment Wizard with the Setup Toolkit
In addition to using the Setup Toolkit project to create your own custom setup project, you can use the Setup Toolkit project in conjunction with the Package and Deployment Wizard. In this case, you use the Setup Toolkit project to customize the screens or other parts of the installation sequence, then use the wizard to create and deploy the package for the application.
For example, you might use the Setup Toolkit and the Package and Deployment Wizard together to add dialog boxes to the installation program, prompting the user to specify whether to install optional features in your application. For example, you may have an online Help file that some users would rather not install. You can add as many installation options as you want.
To add an installation option to your setup program
In the Setup1.vbp project, edit the code for the Form_Load event in the setup1.frm form. To add functionality, you add code after the code block calls the ShowBeginForm function (Sub ShowBeginForm).
The following shows an example of how you would add a dialog box that asks if the user wants to install optional files:
Dim LoadHelp As Integer LoadHelp = MsgBox ("Do you want to install Help? ", vbYesNo) If LoadHelp = vbYes Then CalcDiskSpace "Help" EndIf ' Block of code containing cIcons = CountIcons(strINI FILES) If LoadHelp = vbYes Then cIcons = CountIcons("Help") EndIf ' Block of code containing CopySection strINI_FILES. If LoadHelp = vbYes Then CopySection "Help" EndIf ' Block of code containing CreateIcons, strINI FILES, strGroupName
Close Setup1.frm, save the form and the Setup Toolkit project, and compile to create the Setup1.exe file.
Run the Package and Deployment Wizard, and select Package from the main screen.
Proceed through the wizard, making the appropriate choices. For the example shown above, you would make sure that all optional files the user could choose to install in your custom dialog box were listed in the Add and Remove screen.
Once you are done with the Package and Deployment Wizard, generate the distribution media.
Make any necessary changes to the Setup.lst file. In the example above, you would add a new section with a section you used in the CopySection section of your code. In this case, your section would look something like this:
[Help] File1=MyApp.HL1,MyApp.HLP,$(AppPath),,,10/12/96,2946967,0.0.0
Deploy and test your package.
When the user runs the installation program for the example shown in this procedure, the setup program copies all the BootStrap files to the user's machine and then prompts the user to indicate whether to install the Help files. If the user chooses Yes, the CalcDiskSpace statement determines whether there is sufficient disk space on the user's machine for the Help files. The program then installs all of the files listed with the Setup1 Files section in Setup.lst.
Next, the program tests the LoadHelp flag again. If the user chose to install the Help files, Setup1.exe next executes the CopySection statement for the Help files, and installs the files listed in the [Help] section of Setup.lst.
For More Information See "The Package and Deployment Wizard" earlier in this chapter for more information on features of the wizard.