One of the most promising features of an Internet/intranet environment is the software distribution model. In an Internet/intranet environment, the client browser is responsible for downloading Web pages, ActiveX controls, Java applets, images, and any other files required to display the page. The browser also is responsible for determining whether the file already exists on the machine or needs to be downloaded on the machine.
Before getting further into Web downloads, take a minute to look at the process of software distribution in a typical client/server environment where you create an application and a setup program for the application. The setup program contains all the files required to run your application as well as a program responsible for copying the file to the proper location on a user's machine. Someone then has to go to the user's machine, ask the user to quit what he is doing, and run the setup program to install the application. In large organizations, you can speed up this process by using software programs that specialize in software distribution and maintenance--for example, Microsoft SMS.
What happens when you are ready to release another version of the application? You have to update each user's machine with any files that have been modified or upgraded. Further complicating this environment are the installations of other custom or off-the-shelf applications. How often have you had a user call about an application you wrote that worked fine for more than a year but then suddenly stopped working, only to find that another application recently was installed that improperly replaced a DLL used by your application? Software distribution and maintenance definitely can become a headache.
Now, contrast client/server software distribution to the Internet/intranet environment. In this environment, Web applications are distributed to users without any physical intervention by the application author or any other Information Systems (IS) staff member. If a new user needs the application, you can tell him the URL of the application, and you're done (assuming that he has the proper permissions to use the URL). If you upgrade or make changes to the application, no problem. Change the pages and components on the Website, and you're done! As users access the URL, the browser determines which files have changed and downloads the changes to the user's PC. Other Web applications are installed in a similar fashion, so you don't have to worry about poorly written setup programs overwriting files with older versions. From an administrative point of view, the Internet/intranet environment is much simpler. From a maintenance point of view, the intranet environment again simplifies problems by enabling an administrator to set up directories with the latest components, applets, and applications available for use by anyone with a browser.
So what are the drawbacks? One issue in an Internet environment is security against rogue components or applications. When a component is being downloaded to your PC, you might be concerned that it may damage your machine. After all, it's not like going to the local software store or consulting firm and purchasing a shrink-wrapped software package. Security from rogue applications in a secure company intranet is less of an issue. In an intranet environment, network bandwidth and the overall performance of application download times are major concerns. Despite the concerns, distributing applications via the Web has great potential for companies and organizations to reduce the cost of software ownership and maintenance.
This chapter describes using Visual Basic 5 to create installation packages that enable your ActiveX controls and ActiveX documents to be downloaded and installed via an Internet/intranet environment.
In this section we take a close look at how software is loaded and installed from the Web to the client PC. Before taking a closer look at a Web software installation, you should review some of the important files used in the download process. These files make the distribution of software via the Web possible. The two files used in Web software distribution are Cab Files
Cabinet files (referred to as cab files) are compressed files that contain all the files required to load and install an ActiveX control or ActiveX document on a client machine. Cab files have a file extension of .cab. Typical cab files are the ActiveX control (ocx), the INF file, and any other files or DLLs required by the ActiveX control that are not part of a secondary cab file.
The INF file is compressed into the cab file and is the initialization file for the installation process. The INF file contains all the information on how to download and install the component, including the location for any required secondary cab files. The cab file for the runtime Visual Basic DLL or for DAO is a secondary cab file. The INF file has a file extension of .inf. You can view the .inf file using any text editor--for example, Notepad.
Figure 17.1 shows the download process of ActiveX components or controls via the
Web. Take a look at Figure 17.1 to get a clear understanding of the application download
process via the Web. The Web page MyHTML is on the Web server MyServer. MyHTML contains
a single ActiveX control on the page called MyActiveX.ocx. A person on the
user machine goes to the URL of the Web page MyHTML.
FIGURE
17.1. The Web application download
process. The following steps outline the download process:
One of the prevalent fears of downloading software from the Web is the fear of destructive and harmful controls or components that may damage the client machine. Microsoft has provided several security mechanisms to help prevent harmful software from making it to a user's machine. The security mechanisms with ActiveX controls and ActiveX components follow:
Digital signatures are obtained from a certificate authority. A digital signature enables the Web browser user to determine the author of the control (who may be liable). After the source of the control is identified, the user can decide whether to download the control.
When an ActiveX component or ActiveX control is marked as safe for scripting, the creator of the component or control is making a guarantee that, regardless of how the component or control is used in a script (VBScript or JavaScript), it cannot harm the user's PC in any way. A control or component that tries to obtain information about a user is never safe for scripting. A control that performs any of the following actions as a result of scripting may not be safe for scripting:
When an ActiveX component or ActiveX control is marked as safe for initialization, the creator of the component or control is guaranteeing that, regardless of how it is initialized, it cannot harm the user's PC. Safe for initialization is not as strict a standard as safe for scripting, because safe for initialization is concerned only with how the control is initialized instead of the methods and properties of the control.
Visual Basic 5 includes a utility called the Application Setup Wizard that walks you through the steps required to create a downloadable Web installation package that can be installed on a Windows platform. To create a Web installation package using the Setup Wizard, perform these steps:
FIGURE 17.2. The Select Project and Options dialog box.
FIGURE 17.3.The Internet Distribution Location dialog box.
FIGURE 17.4. The Internet Package dialog box.
FIGURE 17.5. The Safety dialog box.
FIGURE 17.6. The ActiveX Components dialog box.
FIGURE 17.7. The File Summary dialog box.
FIGURE 17.8. The Finished dialog box.
The files created for the setup are placed in the directory you selected in step 3. A subdirectory called Support is created off the selected directory.
I created a Web installation for a simple custom control I developed called Proocx1.ocx. I selected the option to retrieve secondary cab files from the Microsoft Website. On the local directory, I chose to build the Web installation package. The Application Setup Wizard built two files: a cab file called Proocx1.cab and an HTML file to use as an example for using my control called Proocx1.HTM. Listing 17.1 shows this HTML file.
Listing 17.1. An HTML File Generated by the Application Setup Wizard.
<HTML> <!-- If any of the controls on this page require licensing, you must create a license package file. Run LPK_TOOL.EXE in the tools directory to create the required LPK file. <OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"> <PARAM NAME="LPKPath" VALUE="LPKfilename.LPK"> </OBJECT> --> <OBJECT classid="clsid:E097C06E-5B61-11D0-95E3-8FAF3182360A" id=UserControl1 codebase="Proocx1.CAB#version=1,0,0,0"> </OBJECT> </HTML>
The Application Setup Wizard placed the following files used to create the cab file in the Support subdirectory:
You can modify the INF file in the Support directory and regenerate the cab file with your modifications.
In this chapter, you learned how to create a package for Web installations using the Application Setup Wizard in Visual Basic 5. You examined the steps and files involved in the Web download process. Generate Web installations for your custom controls and try them out. If your company has an intranet, you might find Web installation an easy way to cut the cost of software installation and maintenance.