Some Visual Basic 4.0 database applications may call for a one-time-only installation by you, the developer. If that's the case, you can copy the application's .exe, .hlp, and .ocx files, together with any database and ancillary files that may be
required, onto a set of diskettes that you copy to the appropriate directories of the client's computer. If your Visual Basic 4.0 database front-end is to be used by a large number of people, or you want to impress your clients with a sophisticated Setup
application similar to those used to install mainstream Windows applications, you need to create "official" distribution diskettes.
Visual Basic 4.0 includes an Application SetupWizard and a Setup toolkit to create programs that install the files needed by your database applications. This chapter describes how to use the SetupWizard, how the Setup application created by the wizard
appears to recipients of your distribution diskettes, and how to customize the standard Setup application to conform to special requirements of your Visual Basic 4.0 database applications.
The Visual Basic 4.0 SetupWizard is based on the design of wizards included with Microsoft's Word 7.0, Excel 7.0, and Access 95a step-by-step guided format that has, by now, become familiar to millions of Microsoft productivity application users
worldwide. The Visual Basic 4.0 SetupWizard provides the following benefits:
The Visual Basic SetupWizard makes a single set of distribution diskettes each time you execute it. If you send the SetupWizard's output to a disk directory for network distribution or for later CD-ROM mastering, the SetupWizard places your application's compressed files in a single directory you specify. If you send the SetupWizard's output directly to diskette, the SetupWizard places your application's compressed files in a subdirectory named \SetupWiz of whatever directory your Visual Basic project is stored in. You can create additional diskette sets by saving a SetupWizard template (as described in the "Running SetupWiz.exe" section, later in this chapter), and then later loading the template in SetupWizard to copy the compressed files onto another set of diskettes. Alternatively, if you want to duplicate the Visual Basic diskettes, you can create a \Disk# subdirectory on your hard disk for each of your application's distribution diskettes, and then copy the diskette files to create the image in the appropriate subdirectory.
When an end-user installs your application with the Setup.exe and Setup132.exe programs created by the SetupWizard and all of the application's required files are copied to the appropriate directories, an entry on the Windows 95 Start | Programs menu
is automatically created for your application (or a program group and icon in Windows NT) and appropriate entries are made in the Windows Registry database.
The sections that follow describe the steps involved in using the Visual Basic SetupWizard to create distribution diskettes.
Using the SetupWizard is probably the easiest way to create distribution diskettes for your application. This chapter, therefore, concentrates on using the SetupWizard and on how to modify the files that the SetupWizard produces to customize your
application's installation. The example shown in this section uses the files for the Drilldown application (Drill_dn.vbp) that are contained in your \Ddg_VB4\32_bit\Chaptr12 folder, plus Graphs.mdb, which is located in your \Ddg_VB4\32_bit\Chaptr11 folder.
Before you start the distribution-diskette production process, make sure you have two or more empty, formatted diskettes ready. Smaller applications that do not use the data-access, report-generation, and graphing features of Visual Basic usually fit on one diskette. (The SetupWizard automatically employs Compress.exe to compress the distribution files.) Two to four diskettes usually are required for Visual Basic 4.0 database applications. The Drill_dn.vbp project used in this example requires four 1.44MB floppy diskettes, for example.
If you elect to send output to a disk directory for network distribution or mastering a CD-ROM disk, create the destination directory ahead of time.
To create distribution diskettes for your Visual Basic 4.0 database application, follow these steps:
If you have not compiled your application to an .exe or .dll file, or the .exe or .dll file for your application is in another directory, the wizard creates the file for you. If you tick the check box titled Rebuild the project's EXE file, the wizard will do so at this point.
Figure 27.2. Using the Open dialog to specify the location of the .vbp file.
You can only use remote OLE automation servers if you have the Visual Basic 4.0 Enterprise Edition. For Visual Basic Professional and Standard editions, you may only include local OLE servers in your application.
Figure 27.5. Choosing the data access engines to be installed with your application.
The SetupWizard automatically installs the Jet 3.0 database engine, along with any database engines directly referenced in your code. You only need to choose additional database engines if your application permits the user to make open-ended choices about what databases the application will open. Contrary to the notes in the Visual Basic documentation and in the Step 2 dialog of the SetupWizard, you don't need to create an additional set of setup disks if you include ODBC drivers. The wizard checks your Registry database to determine which ISAM and ODBC database engines you have installed on your computer.
Figure 27.9. Choosing the deployment mode for your application.
The SetupWizard is not omniscient; it is not able to determine if database file(s), help files, ReadMe.txt, or other ancillary files are required by your application. You must add all such required files in step 7 of the wizard.
Use the Dependency Of text box to determine whether you can safely remove a selected file in the list. If a file in the list is a dependency of more than one object in the project, the Dependency Of text box changes to a drop-down list, as shown in Figure 27.10.
Figure 27.10. Step 7 of the wizard enables you to fine-tune the list of distribution files.
You should heed the advice to "scan the distribution disks for viruses." Checking distribution diskettes for viruses saves the embarrassment of being advised by your client that you infected (or attempted to infect) his or her computer. However, the wizard forgets to mention that if you find a virus on the diskettes, you also should scan your fixed disk for viruses immediately.
The SetupWizard has the capability to create distribution diskettes for the majority of Visual Basic 4.0 database applications. You can modify the template application for the SetupWizard, whose files are specified in Setup1.vbp, to add your firm's or
your client's logo to the Setup application.
If you decide to modify any of the template files specified in Setup1.vbp, be sure you make a duplicate copy of the files, either in a different directory or on diskette, before making any changes.
The Swdepend.ini file, located in your \Windows directory, is the source of the SetupWizard's information on dependency requirements for various Visual Basic 4.0 application components. The SetupWizard uses the information in the Swdepend.ini file to
determine which components will be required for your application at runtime. The Swdepend.ini file contains information about files required for all Visual Basic applications (such as the VB40032.dll runtime library), as well as information about files
required to implement specific .ocx controls. The Swdepend.ini file is installed on your computer when you install Visual Basic 4.0 and the SetupWizard. You may wish to modify the Swdepend.ini file to add dependencies for custom controls that you develop
yourself or purchase from a third-party vendor. The following is a partial listing of the Swdepend.ini file, showing the dependencies section universal to all Visual Basic 4.0 applications, plus the dependencies section for the Jet 3.0 database engine:
[SetupWiz-32] Register= Dest= Uses1=C:\WINDOWS\SYSTEM\stkit432.dll SetupProj=D:\Visual Basic 4\setupkit\setup1\setup1.vbp BootStrap=D:\Visual Basic 4\setupkit\kitfil32\setup.exe VBExe=D:\Visual Basic 4\vb32.exe RemoveInstallEXE=D:\Visual Basic 4\setupkit\kitfil32\ST4UNST.EXE Drive1=1.2 MB Disk,1213952,512 Drive2=1.44 MB Disk,1457664,512 Drive3=720 KB Disk,730112,1024 Drive4=360 KB Disk,362496,1024 Uses2= CreatedSW=1 [VB Runtime 0409-32] Register= Dest=$(WinSysPath) Uses1=VB40032.DLL Uses2=ven2232.olb Uses3=olepro32.dll Uses4=msvcrt20.dll Uses5=msvcrt40.dll Uses6=ctl3d32.dll Uses7= [DAO3032.DLL] Register=$(DLLSelfRegister) Dest=$(MSDAOPath) Uses1=MSJT3032.DLL Uses2=
A full discussion of the syntax of the Swdepend.ini file is beyond the scope of this book. Contrary to the text of Chapter 30, "Distributing Your Applications," of the Visual Basic Programmer's Guide, there is no Swdepend.txt file provided with Visual Basic 4.0. Instead, you can find the full syntax for the Swdepend.ini file in the Visual Basic ReadMe.hlp file; search for the topic "setup toolkit" in the online help system.
Every time you create a new set of distribution files for one of your Visual Basic 4.0 applications, the SetupWizard creates a new Setup.lst file for that application. The Setup.lst file is placed on Disk1 of the distribution diskettes, or into the
disk directory you specified for your distribution files. The Setup.lst file is organized into several sections. The [BootStrap] section indicates which files must be copied to the end-user's hard disk for the Setup program to run. When a user installs
your application, the Setup.exe program first loads, then reads Setup.lst to determine the required bootstrap files, copies the bootstrap files, and executes the customized Setup132.exe program for your application. The customized Setup132.exe reads the
remainder of the Setup.lst file to copy the remaining files onto the user's hard disk and to properly register your application's components.
Template files can save you time when using the SetupWizard to create additional sets of distribution diskettes or to create distribution diskettes with minor changes to the list of files required by your application. The following listing shows the
entries that the preceding example creates in the Drill_dn.vbz template file when you click the Save Template button after the SetupWizard has completed making the distribution diskettes:
[SetupWiz] VBExe=D:\Visual Basic 4\vb32.exe SetupProj=D:\Visual Basic 4\setupkit\setup1\setup1.vbp BootStrap=D:\Visual Basic 4\setupkit\kitfil32\setup.exe RemoveInstallEXE=D:\Visual Basic 4\setupkit\kitfil32\ST4UNST.EXE CompressToDir=C:\DDG_VB4\32_BIT\Chaptr12\SetupWiz\ [Flags] AppTitle=Drill_dn DefaultDir=$(ProgramFiles)\Drill_dn MakeFilePath=C:\DDG_VB4\32_BIT\Chaptr12\Drill_dn.Vbp,0 Disk Drive=-1 Disk Type=D:\ddg4 tests\ AppExeName=C:\DDG_VB4\32_BIT\Chaptr12\Drill_dn.EXE Deployment=0 RemoteProvider=0 DataAccess=-1 FilesChanged=0 CheckSum=228546 [Dependencies] File1=GSWDLL32.DLL,0,32762 File2=C:\WINDOWS\SYSTEM\COMDLG32.OCX,0,32764 File3=C:\WINDOWS\SYSTEM\OLEPRO32.DLL,0,32763 File4=C:\PROGRAM FILES\COMMON FILES\DAO\DAO3032.DLL,0,32763 File5=C:\WINDOWS\SYSTEM\GRID32.OCX,0,32764 File6=C:\WINDOWS\SYSTEM\THREED32.OCX,0,32764 File7=C:\WINDOWS\SYSTEM\GRAPH32.OCX,0,32764 [DB Drivers] File1=Excel 5.0,Excel 5.0,1,0 File2=Excel 4.0,Excel 4.0,1,0 File3=Excel 3.0,Excel 3.0,1,0 File4=Paradox 3.X,Paradox 3.X,1,0 File5=Paradox 4.X,Paradox 4.X,1,0 File6=Paradox 5.X,Paradox 5.X,1,0 File7=Text,Text,1,0 File8=dBase III,dBase III,1,0 File9=dBase IV,dBase IV,1,0 File10=dBase 5.0,dBase 5.0,1,0 File11=FoxPro 2.0,FoxPro 2.0,1,0 File12=FoxPro 2.5,FoxPro 2.5,1,0 File13=FoxPro 2.6,FoxPro 2.6,1,0 File14=FoxPro 3.0,FoxPro 3.0,1,0 File15=FoxPro DBC,FoxPro DBC,1,0 File16=Lotus WK1,Lotus WK1,1,0 File17=Lotus WK3,Lotus WK3,1,0 File18=Lotus WK4,Lotus WK4,1,0 File19=Jet 2.x,Jet 2.x,0,0 [Files] File1=C:\WINDOWS\SYSTEM\VB40032.DLL,0,$(WinSysPath),,|32767|,-1,-1,0,0,,,0 File2=C:\WINDOWS\SYSTEM\ven2232.olb,0,$(WinSysPathSysFile),,|32767|10|,-1,0,0,0,,,0 File3=C:\WINDOWS\SYSTEM\olepro32.dll,0,$(WinSysPath),$(DLLSelfRegister),|32767|7|32763|21|22|23|,-1,-1,0,0,,,0 File4=C:\WINDOWS\SYSTEM\msvcrt20.dll,0,$(WinSysPathSysFile),,|32767|,-1,0,0,0,,,0 File5=C:\WINDOWS\SYSTEM\msvcrt40.dll,0,$(WinSysPath),,|32767|7|21|22|23|,-1,-1,0,0,,,0 File6=D:\Visual Basic 4\setupkit\kitfil32\Sys32\ctl3d32.dll,0,$(WinSysPathSysFile),,|32767|,-1,0,0,0,,,0 File7=C:\WINDOWS\SYSTEM\GSWDLL32.DLL,0,$(WinSysPath),,|32762|23|,-1,-1,0,0,,,0 File8=C:\WINDOWS\SYSTEM\COMDLG32.OCX,0,$(WinSysPath),$(DLLSelfRegister),|32764|,-1,-1,0,0,,,0 File9=C:\WINDOWS\SYSTEM\MFC40.DLL,0,$(WinSysPath),$(DLLSelfRegister),|7|21|22|23|,-1,-1,0,0,,,0 File10=C:\PROGRAM FILES\COMMON FILES\DAO\DAO3032.DLL,0,$(MSDAOPath),$(DLLSelfRegister),|32763|,-1,-1,0,0,,,0 File11=C:\WINDOWS\SYSTEM\MSJT3032.DLL,0,$(WinSysPathSysFile),,|9|,-1,0,0,0,,,0 File12=C:\WINDOWS\SYSTEM\MSJTER32.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File13=C:\WINDOWS\SYSTEM\MSJINT32.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File14=C:\WINDOWS\SYSTEM\VBAJET32.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File15=C:\WINDOWS\SYSTEM\VBDB32.DLL,0,$(WinSysPath),,|10|,-1,-1,0,0,,,0 File16=C:\WINDOWS\SYSTEM\MSRD2X32.DLL,0,$(WinSysPathSysFile),$(DLLSelfRegister),|10|32761|,-1,0,0,0,,,0 File17=C:\WINDOWS\SYSTEM\MSWNG300.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File18=C:\WINDOWS\SYSTEM\ODBCJT32.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File19=C:\WINDOWS\SYSTEM\ODBCJI32.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File20=C:\WINDOWS\SYSTEM\ODBCTL32.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File21=C:\WINDOWS\SYSTEM\VBAR2232.DLL,0,$(WinSysPathSysFile),,|10|,-1,0,0,0,,,0 File22=C:\WINDOWS\SYSTEM\GRID32.OCX,0,$(WinSysPath),$(DLLSelfRegister),|32764|,-1,-1,0,0,,,0 File23=C:\WINDOWS\SYSTEM\THREED32.OCX,0,$(WinSysPath),$(DLLSelfRegister),|32764|,-1,-1,0,0,,,0 File24=C:\WINDOWS\SYSTEM\GRAPH32.OCX,0,$(WinSysPath),$(DLLSelfRegister),|32764|,-1,-1,0,0,,,0 File25=C:\WINDOWS\SYSTEM\gsw32.exe,0,$(WinSysPath),,|23|,-1,-1,0,0,,,0 File26=C:\DDG_VB4\32_BIT\Chaptr12\Drill_dn.EXE,0,$(AppPath),$(EXESelfRegister),|32766|,-1,0,0,0,,,0
The [SetupWiz] section of the .vbz file indicates which file to execute to compile the VisualBasic code, where the template for the Setup132.exe program is located, where the Uninstall program files are located, and in which directory the compressed
distribution files should be deposited. Next, the [Flags] section contains information such as the application's title, the default installation directory, the name for the compiled executable, and other information about your application. The
[Dependencies] section lists the files that provide objects on which your application is dependentsuch as the Common Dialog .ocx file. The [DB Drivers] section specifies information about the database engine drivers to be installed with your
application, while the [Files] section of the .vbz file specifies the files that are required for use in addition to your Visual Basic .exe file. Additional required files, which are installed in directories other that your application's directory and
\Windows\System, are also specified in the [Files] section.
To use an existing template file with the SetupWizard, follow these steps:
If your application includes OLE custom controls or uses OLE Automation, the Setup application installs all of the necessary OLE server files in the appropriate directories on the recipient's computer. The Setup132.exe program, created by the
SetupWizard for your application, will automatically register any OLE components included in your application. For remote automation servers, Setup132.exe executes the Clireg32.exe (Client Registration) utility. Clireg32.exe is automatically included in
the Setup.lst file for remote automation applications. (You must have the Visual Basic 4.0 Enterprise Edition to create or use remote automation OLE. Chapter 23, "Creating and Managing Remote Automation Objects," describes remote OLE automation
in Visual Basic in more detail.)
The operation of Setup.exe and Setup132.exe is similar to other "two-stage" setup applications, such as those used to install Access 95, Word for Windows, or Excel. The following is the sequence of events as seen from the recipient's
perspective when installing your Visual Basic database application:
The recipient can enter any directory in which he or she wants to install the application. Thus, you cannot count on the application being installed in C:\Drill_dn. If you hard-coded the installation directory for the database file(s), you have two choices: create the directory and install the database file(s) with code you add to Setup1a.frm and then recompile Setup1a.vbp, or change the code in your application to substitute App.Path for the hard-coded path.
If you follow the steps in the preceding sections and create four distribution diskettes for the Drilldown application and then install the application with Setup132.exe on your fixed disk, Drill_dn.exe will run only if Graphs.mdb is located in your
\Ddg_VB4\32_bit\Chaptr10 directory. The location of Graphs.mdb is hard-coded into the application. Drill_dn.exe can use the copy of Graphs.mdb that Setup132.exe places in the application directory by replacing the hard-coded database file location with
App.Path and recompiling Drill_dn.exe. (Alternatively, you could use the File Details button in step 7 of the SetupWizard to alter the destination directory of the Graphs.mdb file.) Using hard-coded directory paths in production programs is not
recommended.
In previous versions of Windows, removing applications, or providing a means for users to remove your applications, was often difficult, especially if your application required the installation of shared components such as OLE servers. Visual Basic
4.0's SetupWizard makes it easy to create an Uninstall utility for your applicationsin fact, the SetupWizard automatically creates an Uninstall option for all of your applications. (This action is in keeping with the "Designed for Windows
95" logo requirement that each application must provide a means of uninstalling itself and correctly decrementing the count of shared components in use.)
When Setup.exe and Setup132.exe install your application, they create a special file, St4unst.log, in your application's installation directory. This installation log contains a record of all files added to the computer system, and all registry entries
created or modified during your application's installation. Setup132.exe also adds your application to the list of installed applications in the Control Panel's Add/Remove Applications applet.
Your application's user may uninstall your application, removing all files and Registry entries that were created or added to the computer during your application's installation. The Add/Remove Applications applet in the Windows 95 control panel
reads the St4unst.log file in order to "unwind" the changes that your application installation made.
To remove your application, an end-user follows these steps:
The dialog shown in Figure 27.20 only appears if the shared component's user count in the Registry has been decremented to 0 by the removal of your application. Properly installed Windows 95 applications (such as Visual Basic 4.0 applications installed with the Setup.exe program created by the SetupWizard) increment the user count of shared components in the Registry whenever the application is installed.
Figure 27.20. The dialog asking a user whether to keep or remove a shared component.
Visual Basic 4.0 applications are removed by executing the St4unst.exe application, which is automatically installed with your applicationSt4unst.exe is one of the Setup.exe bootstrap files. St4unst.exe is also executed whenever a user cancels your application's installation.
If you routinely distribute Visual Basic 4.0 database applications that must be customized for individual users, you'll likely need to develop your own Setup application. As an example, database front-ends may need to be customized to take into account
the network operating system with which the version is to be used, different methods of communicating with mainframe databases, and/or whether the application is to be run on monochrome laptop computers. For example, if your client uses Information
Builder's EDA/SQL, and your front-end application employs EDA/Link for Windows and the EDA/Extender for Microsoft ODBC, you may need to configure different versions of your database applications for conventional coax (IBM 3270 emulation), HLLAPI
(High-level link API with Wall Data's Rumba emulator), TCP/IP, or dial-up (asynchronous) communication. Each of these methods for establishing mainframe connectivity require installation of different configuration and operating files on the client
computer.
Another reason to create your own Setup application is to automate any required modifications to the client computer's Registry database (and, occasionally, Autoexec.bat and Config.sys files). As an example, EDA/Link for Windows requires that the \EDA
directory (or the directory in which the EDA/Link files are installed) be on the DOS path. Many computer users have never even looked at their Registry, Autoexec.bat, or Config.sys files, let alone used a text editor to modify them.
The sections that follow describe the principles you use to modify the Setup application for custom Visual Basic 4.0 installations.
As mentioned earlier in this chapter, you can use the files specified by Setup1.vbp as a template to create your own Setup application. The modifications you are most likely to make are as follows:
With the exception of modifying Swdepend.ini, the additional features described in the preceding list can be implemented by minor changes to the code in the Form_Load procedure of Setup1.frm. You can add dialogs to Setup1.vbp so that the recipient can
select the type of installation he or she needs. These modifications follow conventional Visual Basic programming practices. To install the additional files or create new program items, copy the code fragments in the Form_Load event-handler and change the
arguments of the procedure calls to specify the file you want to add.
Windows 95 is supposed to do away with the myriad of configuration files that Windows 3.1+ users were burdened with. In practice, however, some of these configuration files persist (in particular, the Autoexec.bat and Config.sys files, which have been
part of DOS since its beginning). Primarily, these two files remain to support legacy hardware devices that require the loading of real-mode device drivers, and for setting environment variables for the operating system. Typically, you'll only need to
examine or modify the contents of a recipient's Autoxec.bat or Config.sys files if your application needs to look at or set specific environment variables (such as the TEMP environment variable, which points to the location of the default temporary working
directory for Windows and other applications), or if you need to ensure that your application directory (or the installed directory of an external component) is part of the DOS search path.
You can incorporate Visual Basic binary file instructions and functions in your Setup application to read the Autoexec.bat and Config.sys files on the recipient's fixed disk to determine if you need to make modifications to these files so that your
application will execute properly.
Although you can open and write Autoexec.bat and Config.sys with the conventional, line-oriented For Input and For Output qualifiers, using the For Binary qualifier to manipulate the content of these two files with a single string
is a safer approach. You parse the string to test for existing entries and then add the required entries to the string. The final step is to write the modified string to the file.
Polite Setup applications advise the recipient with a message box that the Autoexec.bat and Config.sys files may need to be altered. Before making any changes to these files, save a copy of the original versions with the FileCopy instruction and advise the recipient of the names of the backup files. An even more polite approach is to offer the recipient of your application the option of modifying the existing Autoexec.bat and Config.sys files or creating a new set of files that the recipient can inspect before copying over Autoexec.bat and Config.sys.
Creating distribution diskettes is the final step in developing a Visual Basic 4.0 database application, so it is fitting that this chapter closes Database Developer's Guide with Visual Basic 4.0. The objective of this book is to provide DOS and
Windows database developers and Visual Basic 4.0 programmers who are new to database applications with the background needed to create professional-grade database front-ends with the Professional and Enterprise Editions of Visual Basic 4.0. It is hoped
that this objective was accomplished.
Visual Basic is reported to be Microsoft's most successful and profitable language product. Therefore, you can expect Microsoft to continue to release upgrades and extensions to Visual Basic. When this edition was written, Microsoft had just announced
the development of Visual Basic Script and that it also had licensed Sun Microsystem's Java programming language, both of which are intended for Internet and other network-related programming projects. (Java is an object-oriented programming language
designed for programming wide-area and local-area networked applications where the application code is stored on network computers other than the computer executing the application.) Fortunately for Visual Basic developers, Microsoft has given its highest
development priority to ensuring that Visual Basic Script will be an effective competitor to Java and JavaScript in the Internet and intranet realms. It's a reasonably sure bet that the combination of Visual Basic and Jet will be the premiere programming
system for Internet and intranet servers, and that Visual Basic Script will become the language of choice for creating interactive World Wide Web documents.
The remainder of this book consists of a glossary of terms that might be unfamiliar to readers, appendixes that list sources of add-on products, and additional information for Visual Basic programming. Also included are the standard naming conventions
for Visual Basic objects and variables and a detailed index.