Distributing Your Applications
Distributing Your Applications
Distributing Your Applications
others. You can freely distribute any application you create with Visual Basic to
anyone who uses Microsoft Windows. If you are going to distribute your application,
you will need to write or use a setup program that installs your application onto a
user’s machine. This chapter shows you how to create a professional setup program
for your application.
Note If you are using the Control Creation Edition of Visual Basic, some of the material
covered in this document may not be applicable. With the full editions of Visual Basic you have
the ability to create applications, ActiveX documents, and other types of components. Although
some of the terminology may relate to application specific objects such as forms, in most
cases the underlying concepts also apply to ActiveX control creation.
1
Contents
· Creating a Setup Program
· Files You Are Allowed to Distribute
· Using the Visual Basic Setup Wizard
· Using the Setup Toolkit
· Testing Your Setup Program
· Allowing the User to Remove Your Application
· Using the Setup Wizard with the Setup Toolkit
2
—1
Note The Setup Wizard and the Setup Toolkit create setup programs and distribution media
only for Visual Basic applications. To create setup programs for other Windows–based
applications, use the Setup Toolkit provided with that development product or in the Microsoft
Windows SDK.
4
—3
—4
—5
—6
—7
Figure 17.1 Creating a setup program, Setup.lst, and project dependency file
7
—8
1
8
5 Choose your Visual Basic project by typing the path and file name into the Project
File input box or by selecting the Browse button.
6 Select either the Generate Dependency File Only option to create a .dep file only
or the Create a Setup Program/Generate Dependency File to create a Setup
program and a project .dep file. Click the Next button.
1If you want the Setup Wizard to rebuild your project, check the Rebuild the
Project option. If not, uncheck the option before proceeding.
7 If you are missing dependency information for any component in your project, you
will be notified with the Missing Dependencies screen.
2If you know that certain components are already installed on the user’s machine,
or that a listed file does not have dependency files, you may click that file to
proceed.
3You may also proceed without confirming the missing dependencies, although
your project may not function correctly.
1Note If you are missing dependency information for a component that you created in
Visual Basic (or the Setup Wizard informs you that this information is out of date), you
should first use the Setup Wizard to create a .dep file for that component (using these steps
but selecting the .vbp file for the component project), and then restart this process for the
current project.
9
—9
Distribution Options
You can distribute your application applications on floppy disks, compact discs, or on
a network. If you’re going to be using floppy disks, you can choose either Setup
Wizard’s Floppy Disk or Single Directory method. If you plan to distribute on a
compact disc or on a network, you can choose either the Single Directory or the Disk
Directories method.
If you have the Professional or Enterprise Edition, you can distribute your
components over the Internet. For more information, see “Internet Component
Download” later in this chapter. “Installing Remote Automation and Distributed
COM Components” provides specifics about working with Remote Automation and
DCOM, which are available in the Enterprise Edition.
11
Figure 17.3 Choosing distribution options with the Setup Wizard
11
—10
Floppy Disks
To create floppy disks for your application’s setup when you don't need disk images,
select the Floppy Disk option from the Distribution Method screen of the Setup
Wizard. This screen is available when you run the Setup Wizard and select the Create
a Setup Program option.
The Setup Wizard will prompt you for the type of floppy disk (1.44, 1.2, 720, or 360)
and the appropriate floppy drive on your computer. As with most other Setup Wizard
functions, you will then be asked to confirm the project’s files and dependencies.
Once confirmed, the Setup Wizard will determine the layout of the disks, compress
the appropriate files, and then copy them to the disk drive, prompting you to insert
and remove floppy disks as necessary.
You can also use the Disk Directories option to create disk images of your setup
program. The Setup Wizard performs essentially the same actions as for the Floppy
disk option, except that the images are copied to separate directories in a temporary
directory on your computer or a network server rather than to the floppy disk drive.
You can then manually copy the files to disks, put the files on a network server and
allow users to copy them to disks (providing you’re working in a networked
environment), or provide them to a floppy-disk duplication service.
Single Directory
You can create a single directory installation by choosing the Single Directory option.
You can use this option or the Disk Directories option when you want to distribute
your application on a network or a compact disc. This technique simply copies all of
the installation files into a single directory.
When you choose this option, the Setup Wizard will ask you to confirm the project’s
files and dependencies, and then will compress and copy the appropriate files to a
temporary directory on your computer or a network server. By default, the files are
copied to C:\Windows\Temp\SwSetup.
You can then either put the files on an appropriate network server or transfer them to
a compact disc.
—11
—12
12
Creating a Setup Disk for ODBC Applications
For the Professional and Enterprise editions, if you create an application that uses
ODBC and you want to distribute that application, you must create an ODBC Setup
Disk. Before you install your Visual Basic application on the user's machine (using a
setup program you have written), you must install ODBC on the user's machine.
Note If your application uses Remote Data Objects (RDO), you should instruct the user to
install the ODBC drivers before installing your application. If the ODBC drivers are not installed
first, the RDO components will not register.
13
To create an ODBC setup disk
9 Copy all the files in \Odbc subdirectory of the main Visual Basic directory to a disk
or network directory.
10 Before installing your application on the user's machine, run Setup.exe on the
ODBC setup disk or network directory. Either use the Shell function to run
ODBC Setup.exe from your setup program, or label the ODBC setup disk with
a title such as "ODBC Setup Program: Run Setup.exe before installing the
application."
13
Once you have placed the ODBC files on a disk, test the ODBC setup disk on a
machine that does not have ODBC files.
—13
—14
2
14
7Select Install as a shared component and then Yes if you are using Remote
Automation or No if you are using Distributed COM.
8If you select the Remote Automation option, the remote automation files
Racmgr32.exe, Racreg32.dll, Autmgr32.exe, and Autprx32.dll will be added to the
Setup.lst and installed with the server application into the \Windows\System
directory of the remote server.
16 Proceed through the Setup Wizard to create the setup program for the server.
15
The server application is installed on the remote server computer. The setup program
for the server application will install the application and the Remote Automation
files. See Building Client/Server Applications with Visual Basic for more information
about configuring the Remote Automation server.
—15
3
16
11If you want to add a remote server, click the Add Remote button.
23 You will be prompted for the .vbr file of the server application. Locate the file in
your server project’s source directory and choose Open. The .vbr file will be
added to file list, and the Remote Connection Details dialog box will prompt
you for the connection information.
—16
4
17
12If you are using Distributed COM, chose it from the Remote Transport options
and then type the computer name of the remote server into the Network Address
input box.
13If you are using Remote Automation, select it and then either specify the
network address, network protocol, and authentication level or leave them blank to
prompt the client user for this information at run time.
14Select the appropriate options and then click the OK button to return to the
ActiveX Components screen. If both the local (.exe) and remote (.vbr) version of
the remote server component appear in the components list, deselect the local
(.exe) version so that only the remote server is used by your application when
installed.
24 Proceed through the Setup Wizard to create the client application setup.
18
Install the client application on the client user’s machine and follow the Remote
Automation or Distributed COM procedures for using the client and server
applications in unison.
—17
—18
19
The Setup Wizard will create a .cab file, known as the primary .cab file, which
contains the following:
· The project components, such as the ActiveX control, ActiveX DLL, or ActiveX
EXE.
· The .inf file, which contains links to other .cab files that contain Visual Basic
support files and controls, as well as other information, such as whether the
control is safe for scripting and safe for initialization and registry information
as defined by the user. This file replaces the Setup.lst file that the Setup Wizard
creates in the standard setup.
· Reserved space for digital signatures.
· All files that are not in other (secondary) .cab files.
20
Secondary .Cab Files
For ActiveX control projects, ActiveX EXEs, and ActiveX DLLs, all run-time
components — such as Msvbvm50.dll, individual controls, Data Access Objects
(DAO), and Remote Data Objects (RDO) — are packaged into separate .cab files,
digitally signed by Microsoft, and placed on the Microsoft Web site. You can choose
to link your files to the .cab files on the Microsoft Web site, or you can download
local copies of them.
The benefit of using secondary .cab files from an Web site are:
—19
—20
5
22
17If you want to link to secondary .cab files for the Microsoft controls or
components used in your project, select the Download from the Microsoft web
site option. All of the ActiveX controls that ship with Visual Basic contain Internet
information in their companion dependency (.dep) files. The Setup Wizard writes
the appropriate information into the .inf file in the .cab file it creates.
18If you want to use local copies of secondary .cab files, select the Use Local
Copy option. You then enter a URL or UNC path to where the Internet setup will
be able to find these .cab files. Or, you can leave the path blank if the .cab files
will be in the same directory as the primary .cab file that the Setup Wizard creates,
when it is uploaded to the Web server. Blank is the Default.
19Select the appropriate option.
31 You can now mark your components as safe for initialization or scripting.
—21
6
23
20When you mark your components as safe for initialization and scripting, you
are guaranteeing that your component can never cause undesirable behavior on an
end user’s machine, even if used in a Web page that you yourself did not author.
See “Component Safety for Internet Distribution” in Building Internet
Applications for more information.
32 You will continue to step through the Setup Wizard to confirm files and
dependencies. When you reach the Finished! screen, click Finish to create the
Internet download package.
24
Distributing the Internet Setup Package
The Setup Wizard creates a .cab file that contains your component, an .inf file, and
space for digital signing. It also creates a sample .htm file which you can use to refer
to your component from the Web page.
In the above example, we created an Internet download package for an ActiveX
document. The following files were created:
File Description
Actxdoc.cab The.cab file which contains: the ActiveX document (.dll) and
the .inf file.
Actxdoc.htm An HTML file containing sample HTML code.
FirstDoc.vbd The state file for the FirstDoc object in the ActiveX
document.
SecndDoc.vbd The state file for the SecndDoc object in the ActiveX
document.
17
—22
Caution These are the same files used by the Setup Wizard. Therefore, if you modify a file in
the Setup Toolkit (Setup1.exe, for instance), the modified version will be used in subsequent
Setup programs created by the Setup Wizard. Before you modify this project, save a copy to
another directory.
You use the Setup Toolkit by first loading the Setup1.vbp file into Visual Basic and
then making modifications to the look or functionality of the project. In doing so, you
—23
—24
—25
Program Files
These files are essential for your application to run and are useful only in the context
of your application. For example, the application’s .exe file or any data files that your
application may require are considered program files. Program files should be
installed in the application directory. The user is prompted for this directory during
setup. The code in Setup1.vbp demonstrates how to do this. Setup1 will use the
“Program Files” location as the default root location to install applications with
Windows 95. For example, Setup1 will suggest that Project 1 be installed in the
\Program Files\Project1 directory.
Caution When installing a file on the user’s machine, it is imperative that you do not copy an
older version of the file over a new version. The CopyFile function in Setup1.bas uses the
VerInstallFile API function to copy files to the user’s machine. VerInstallFile will not overwrite
an existing file with an older version.
—26
—27
—28
—29
—30
—31
—32
—33
—34
—35
—36