Microsoft Corporation
December 1999
Summary: This article is a supplement to assist Microsoft Visual FoxPro 6.0 developers in using the Visual Studio Installer as an alternative to the Visual FoxPro 6.0 Setup Wizard. (13 printed pages)
Click to download the VFP_VSI.exe sample file.
The Microsoft® Visual Studio® Installer is a great new tool you can use to create customized setups for your Visual FoxPro® distributed applications. It is based on the new Microsoft Windows® installer, which reduces the total cost of ownership (TCO) for your customers by enabling them to efficiently install and configure your products and applications. The new Windows installer is part of the Windows 2000 and Zero Administration Windows (ZAW) efforts to reduce the overall cost of deploying, using, and managing desktop computers.
This article is not meant as a replacement for the Visual Studio Installer (VSI) documentation, which you should read first. It is merely a supplement to assist Visual FoxPro developers in using VSI as an alternative to the Visual FoxPro 6.0 Setup Wizard. We highly recommend you reread the Visual Studio Installer Best Practices section on how to package your application components, available in the VSI documentation.
Additionally, you should read the accompanying tutorial article, “Microsoft Visual FoxPro 6.0 Visual Studio Installer Tutorial,” which walks you through the process of creating an installer package with your Visual FoxPro application.
This article is broken down into sections based on typical distributed application scenarios. At the end, you will find a reference guide to assist you in creating VSI setup scripts.
Many typical Visual FoxPro applications today are built entirely with Visual FoxPro and use native Fox data (that is, .dbc and .dbf files). The following steps are general guidelines to follow for creating a Visual Studio Installer setup for your Visual FoxPro distributed application.
Note The accompanying tutorial, “Microsoft Visual FoxPro 6.0 Visual Studio Installer Tutorial,” provides more details if you are not familiar with the basics of using Visual Studio Installer.
Note If you manually drag and drop files from the Windows Explorer, the application folder structure is not preserved. You need to manually add subfolders to the Application Folder in the File System window to preserve the folder structure.
Merge modules that ship with VSI are installed in the following location:
C:\Program Files\Microsoft Visual Studio\Common\Tools\VSInst\BuildRes
This location includes MSVCRT.MSM and OLEAUT32.MSM. Merge modules can be added to your project in a way that is similar to how you add a file. The Project menu’s Add Merge Module(s) item allows you to do this.
Note Windows 2000 installs files in these last two merge modules under System File Protection. If you are only distributing your application to customers running Windows 2000, you do not need to include these modules.
Important Choose the appropriate Build Type option based on your target customer. Picking the Installer with Windows Installer Loader option will add an extra 2.6 megabytes (MB) to the entire setup, but it is required for customers who do not have the Windows Installer loaded on their machines.
The output of your project is a Microsoft Installer package file (.msi), which any user can double-click to run. See the section Distributing Your Application below for more details.
A common element of many Visual FoxPro applications is ActiveX® Controls. You can include ActiveX Controls with your VSI setups by following these steps:
Common ActiveX Controls—these are the common controls, which ship with Visual FoxPro 6.0 and Visual Studio 6.0. VSI ships with merge modules for most of these controls. Simply add the appropriate merge module for that control (see the Reference Guide below). For example, if your application uses the Treeview control, you should include the MSCOMCTL.MSM merge module.
VBCCE Controls—Visual Basic® 6.0 allows developers to create custom ActiveX Controls. You will need to manually add this control to the project and set certain properties (for example, install location, registration). You can set the Register property for the ActiveX Control file to vsifrSelfReg (1) to register the file (see “Important” below for more details). The install location for this control can be the same as the application if the control is not likely to be shared with other applications. In addition to the actual control, you will also need to include the Visual Basic run-time merge module (MSVBVM60.MSM).
MFC Controls—some of the older controls, such as the Calendar control, use the MFC libraries. You should include the MFC42.MSM merge module if this is the case. As with VBCEE controls, you will need to manually add the control to the project and set various settings.
Third-Party Controls—refer to documentation provided by the vendor on how and where to install the control. Make sure you register the control. The documentation should also provide information on any dependency files needed (for example, MFC, Visual Basic run time). You may also have to add specific Registry keys (use VSI Registry window) for any necessary licensing requirements.
Important To ensure the Microsoft Windows installer knows about your installed files to roll back or advertise them, you must install the files in a manner compliant with Windows Installer requirements. Self-registering your files is not compliant with Windows installer requirements. The Associations Editor in Visual Studio Installer makes it possible for you to install Windows installer-compliant COM objects. For more information, see the Visual Studio Installer documentation.
If you choose to register controls by setting the Register property to vsifrSelfReg, then you should also set the SharedLegacyFile property so that the application can be properly reference counted. This is essential if that control is shared by multiple applications.
Note The Common ActiveX Controls included in the VSI merge modules contain registration information that is Windows installer-compliant.
The VFP6RUN.MSM merge module includes both FOXHHELP.EXE and FOXHHELPPS.DLL files needed to support context HTML Help within your Visual FoxPro 6.0 applications. Besides your application specific .chm file, you will need to include the core HTML Help viewer files. The HTML Help viewer files are available as a redistributable called HHUPD.EXE, which can be downloaded from the MSDN Web site http://msdn.microsoft.com/workshop/author/htmlhelp/download_main.asp. Users will need to run this HHUPD.EXE installer after they run the .msi installer.
If your applications use any of the following data components, you will want to include the Microsoft Data Access Components merge module (MDAC.MSM).
Important The MDAC merge module does not actually contain any MDAC files. It simply provides a check for the installer. If MDAC is not installed on the user’s system, then a message dialog is displayed indicating that the user needs to also install these components. You will still need to include the actual MDAC redistribution setup with your application. This setup (MDAC_TYP.EXE) is included at the following Visual FoxPro 6.0 SP3 location:
<vfproot>\Distrib.src\System\
You can also obtain MDAC_TYP.EXE from the Microsoft web site. Users will need to run the MDAC_TYP.EXE installer manually after they run the .msi installer.
Often, applications consist of components that are shared by multiple applications. Visual FoxPro frameworks, foundation classes, and other shared files and class libraries are examples of these types of components. As described in the Visual Studio Installer documentation, it is recommended that these types of files be combined into merge modules, which can be included later with any application installer package. This ensures that files are always installed in a consistent manner.
The Visual Studio Installer also lets you combine files (as well as shortcuts, registry keys, and so on) into a common component. However, the Visual Studio Installer best practice recommendation is to make each file included in your installer project a component. One of the limitations of combining multiple files into a single component is that all files must be installed in the same directory on the target machine. A good example of when you might combine multiple files into a single component is Visual FoxPro binary files (for example, dbf/fpt, scx/sct, frx/frt, lbx/lbt).
A specific example of components that could be packaged into merge modules is a Visual FoxPro COM Server (both Local .exe and In-Proc .dll servers). You can then add your COM Server merge module to any VSI installer project.
Correctly installing and registering COM objects is necessary to take advantage of Windows installer rollback and advertising features. As explained in the VSI documentation, two powerful features of the Windows installer are the abilities to:
To support rolling back component installation and registration if your product installation fails and component advertisement on the target machine, you must register installed COM objects by establishing the necessary associations. You can choose not to do so by self-registering your installed COM objects, but this sacrifices the enhanced Windows installer rollback and advertising functionality.
With traditional scripted setup programs, self-registration was the accepted method for installing COM objects, and it is still a viable method. However, the Windows installer cannot perform rollback installations and registration of self-registered COM objects, and it cannot advertise those objects. This is because self-registered COM objects do not pass their installation and registration information to the Windows installer.
To ensure that the Windows installer knows enough about your installed COM objects to perform a rollback on or advertise them, you must install those COM objects in a manner compliant with Windows installer requirements. With the Associations editor in Visual Studio Installer, you can install Windows installer-compliant COM objects.
Additionally, type library information for the COM Server must also be captured because it is also registered in the Registry. With Visual FoxPro, a type library can be bound inside of the .exe or .dll server file, or exist separately as a .tlb file.
When authoring a VSI setup to include a Visual FoxPro COM Server, you have two options for handling server registration:
Option 1: You can set the Register property for the COM Server file to vsifrSelfReg (1). This option performs the older style self-registration. However, you lose many of the Windows installer capabilities just mentioned. It is the easiest option for authoring your VSI setup.
Option 2: The recommended approach for registering COM servers requires a little more work. You will need to manually add Registry keys and COM Object associations to the VSI setup. Let’s walk through an example (note that all the sample files are included with the sample download at the top of this article):
You can optionally add the server’s .vbr file, which is used by CLIREG32.EXE to register a COM server remotely.
Note The Visual Studio Installer does not support post-install actions as the Visual FoxPro Setup Wizard does, so you need to run CLIREG32.EXE separately after the setup.
VB5SERVERINFO
VERSION=1.0.0
HKEY_CLASSES_ROOT\foxdemo1.foxsvr1 = foxdemo1.foxsvr1
HKEY_CLASSES_ROOT\foxdemo1.foxsvr1\NotInsertable
HKEY_CLASSES_ROOT\foxdemo1.foxsvr1\CLSID = {F802CDC0-D690-4603-9936-6860B86A3163}
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163} = foxdemo1.foxsvr1
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163}\ProgId = foxdemo1.foxsvr1
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163}\VersionIndependentProgId = foxdemo1.foxsvr1
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163}\InProcServer32 = foxdemo1.dll
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163}\InProcServer32\”ThreadingModel” = Apartment
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163}\TypeLib = {1995B333-9FA9-4819-A320-DA074AB37324}
HKEY_CLASSES_ROOT\CLSID\{F802CDC0-D690-4603-9936-6860B86A3163}\Version = 1.0
HKEY_CLASSES_ROOT\INTERFACE\{DB1D22E5-826B-47DF-95DD-516527BD6E8E} = foxsvr1
HKEY_CLASSES_ROOT\INTERFACE\{DB1D22E5-826B-47DF-95DD-516527BD6E8E}\ProxyStubClsid = {00020424-0000-0000-C000-000000000046}
HKEY_CLASSES_ROOT\INTERFACE\{DB1D22E5-826B-47DF-95DD-516527BD6E8E}\ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
HKEY_CLASSES_ROOT\INTERFACE\{DB1D22E5-826B-47DF-95DD-516527BD6E8E}\TypeLib = {1995B333-9FA9-4819-A320-DA074AB37324}
HKEY_CLASSES_ROOT\INTERFACE\{DB1D22E5-826B-47DF-95DD-516527BD6E8E}\TypeLib\”Version” = 1.0
; TypeLibrary registration
HKEY_CLASSES_ROOT\TypeLib\{1995B333-9FA9-4819-A320-DA074AB37324}
HKEY_CLASSES_ROOT\TypeLib\{1995B333-9FA9-4819-A320-DA074AB37324}\1.0 = foxdemo1 Type Library
HKEY_CLASSES_ROOT\TypeLib\{1995B333-9FA9-4819-A320-DA074AB37324}\1.0\0\win32 = foxdemo1.dll
HKEY_CLASSES_ROOT\TypeLib\{1995B333-9FA9-4819-A320-DA074AB37324}\1.0\FLAGS = 0
If you take a close look at the .vbr file, you will see that there are four groups of Registry keys that we need to add. These are keys for PROGID, CLSID, INTERFACE, and TYPELIB. All of the keys fall under the HKEY_CLASSES_ROOT Registry hive. It is a good idea to open up the Registry using REGEDIT to see how the keys should appear. You can later run your .msi setup to see if the Registry keys are being written out properly.
oServer = CreateObject(“foxdemo1.foxsvr1”)
The PROGID keys are simply added to your VSI project through the Registry window. Right-click the appropriate node to add new Keys and String Values. You can copy and paste values from the .vbr file to save time.
Note A few Registry keys written out during a self-registration are not included in the .vbr file (Implemented Categories and Programmable). The sample includes these. You can also see them in the Registry using REGEDIT.
Once you have entered all of the Registry keys except the one with the reference to the actual server file, you need to add a COM Object association for this file using the Associations window. The VSI documentation explains this. Make sure you enter the proper CLSID value.
Note The Windows installer actually adds an extra string value to this Registry key during install. This value may look a little weird, but it is needed by the Windows installer for features such as Advertising.
[TARGETDIR]foxdemo1.dll
During the install process, the wildcard placeholder is replaced with the actual value of the folder specific to the target machine. In addition, you will need to use a Windows Installer property for the HELPDIR key. The Appendices below have some of the common Windows installer properties. Refer to the Windows 2000 Platform SDK for more details.
You are now done and simply need to build your .msi installer package or .msm merge module. It is always a good idea to thoroughly test any setup such as this where you have manually entered Registry keys.
Tip If you are installing your COM Server onto a Windows 2000 or Windows 98 (Second Edition or later) machine, you should seriously consider installing the component directly to the application directory so that it is isolated from other applications. In order to do this, you must use Option 2 to register your component. The one difference to make in your setup is not to use the Associations window for handling the CLSID registry keys. Instead, you should simply add an entry in the Registry window with the name of your COM server but without a path. If no path is included, COM will first look in the application folder for that component. For more details on isolating components, go to http://search.microsoft.com/us/dev/default.asp and search on “DLL Hell.”
The VFP6RUN.MSM file includes the standard language-neutral resource file (VFP6RENU.DLL), which is used for all English (US) shipping applications. If you want to include support for another localized resource file (VFP6Rxxx.DLL), simply drop that file into the project and install it in the Windows System folder. It does not need to be registered. You should set the File’s DoNotUninstall property to True. For example, include VFP6RDEU.DLL for the German run-time resource file.
Language | Resource File |
German | VFP6RDEU.DLL |
French | VFP6RFRA.DLL |
Spanish | VFP6RESP.DLL |
Simplified Chinese | VFP6RCHS.DLL |
Traditional Chinese | VFP6RCHT.DLL |
The Visual FoxPro 6.0 Setup Wizard should still be used for the following scenarios:
When you distribute your application, you should still follow many of the same guidelines mentioned in the Visual FoxPro documentation. VSI setups (.msi files) use the new Windows Installer technology, which is available on certain platforms. The following steps are general installation instructions when distributing your application to customers. There are two basic scenarios to consider:
—or—
Install any additional required setups (users will need to run these separately):
Note Building an installer with the Windows installer bootstrap loader creates these distinct files as part of your installer package. You must include all of these files on the media that you choose to distribute your application:
The VFP6RUN.MSM merge module properly installs the necessary files to support your Visual FoxPro distributed applications, including COM servers, Active Documents, and normal Windows executables. As with the Visual FoxPro 6.0 SP3 Setup Wizard, run-time files are installed and registered in the Windows System directory. Because the VFP6RUN.MSM merge module is properly authored for Windows installer file installation and registration, it can take advantage of rollback and advertising features. The following files are included in the VFP6RUN merge module:
File |
VFP6R.DLL |
VFP6T.DLL |
VFP6RENU.DLL |
VFP6RUN.EXE |
FOXHHELP.EXE |
FOXHHELPPS.DLL |
Core Components | Merge Module |
OLE Automation Support Files | OLEAUT32.MSM |
Microsoft Visual C Run-Time Libraries | MSVCRT.MSM |
Microsoft Component Category Manager Library | COMCAT.MSM |
Microsoft Foundation Classes | MFC42.MSM |
Visual Basic 6.0 Run-Time Library | MSVBVM60.MSM |
Microsoft Data Access Components 2.1 | MDAC.MSM |
ActiveX Controls | Merge Module |
Microsoft Animation Control (v5.0)
Microsoft UpDown Control (v5.0) |
COMCT232.MSM |
Microsoft Coolbar Control (v6.0) | COMCT332.MSM |
Microsoft TabStrip Control (v5.0)
Microsoft Toolbar Control (v5.0) Microsoft StatusBar Control (v5.0) Microsoft ProgressBar Control (v5.0) Microsoft TreeView Control (v5.0) Microsoft ListView Control (v50) Microsoft ImageList Control (v5.0) Microsoft Slider Control (v5.0) |
COMCTL32.MSM |
Microsoft Common Dialog Control (v6.0) | COMDLG32.MSM |
Microsoft Data Bound Grid Control (v5.0) | DBGRID32.MSM |
Microsoft DBList Control (v6.0)
Microsoft DBCombo Control (v6.0) |
DBLIST32.MSM |
Microsoft Multimedia Control (v6.0) | MCI32.MSM |
Microsoft Chart Control (v6.0) (OLE DB) | MSCHRT20.MSM |
Microsoft Animation Control (v6.0)
Microsoft UpDown Control (v6.0) Microsoft MonthView Control (v6.0) Microsoft Date and Time Picker Control (v6.0) Microsoft Flat ScrollBar Control (v6.0) |
MSCOMCT2.MSM |
Microsoft TabStrip Control (v6.0)
Microsoft Toolbar Control (v6.0) Microsoft StatusBar Control (v6.0) Microsoft ProgressBar Control (v6.0) Microsoft TreeView Control (v6.0) Microsoft ListView Control (v6.0) Microsoft ImageList Control (v6.0) Microsoft Slider Control (v6.0) Microsoft ImageComboBox Control (v6.0) |
MSCOMCTL.MSM |
Microsoft Communications Control (v6.0) | MSCOMM32.MSM |
Microsoft FlexGrid Control (v6.0) | MSFLXGRD.MSM |
Microsoft Hierarchical FlexGrid Control (v6.0) | MSHFLXGD.MSM |
Microsoft Internet Transfer Control (v6.0) | MSINET.MSM |
Microsoft MAPI Session Control (v6.0)
Microsoft MAPI Message Control (v6.0) |
MSMAPI32.MSM |
Microsoft Masked Edit Control (v6.0) | MSMASK32.MSM |
Microsoft Winsock Control (v6.0) | MSWINSCK.MSM |
Microsoft Picture Clip Control (v6.0) | PICCLP32.MSM |
Microsoft SysInfo Control (v6.0) | SYSINFO.MSM |
Microsoft Tabbed Dialog Control (v6.0) | TABCTL32.MSM |
Property name | Brief description of property |
SourceDir | Root directory containing the source files. |
TARGETDIR | Location into which the installation package is copied during an administrative installation. |
AppDataFolder | Full path to the Application Data folder for the current user. |
CommonFilesFolder | Full path to the Common Files folder for the current user. |
DesktopFolder | Full path to the Desktop folder. |
FavoritesFolder | Full path to the Favorites folder for the current user. |
FontsFolder | Full path to the Fonts folder. |
NetHoodFolder | Full path to the NetHood folder for the current user. |
PersonalFolder | Full path to the Personal folder for the current user. |
PrintHoodFolder | Full path to the PrintHood folder for the current user. |
ProgramFilesFolder | Full path to the Program Files folder. |
ProgramMenuFolder | Full path to the Program Menu folder. |
RecentFolder | Full path to the Recent folder for the current user. |
SendToFolder | Full path to the SendTo folder for the current user. |
StartMenuFolder | Full path to the Start menu folder. |
StartupFolder | Full path to the Startup folder. |
System16Folder | Full path to folder for 16-bit system DLLs. |
SystemFolder | Full path to the System folder. |
TempFolder | Full path to the Temp folder. |
TemplateFolder | Full path to the Template folder for the current user. |
WindowsFolder | Full path to the Windows folder. |
WindowsVolume | The volume of the Windows folder. |