Visual Basic Concepts

Where to Install Files on the User's Machine

See Also

Before writing your setup program, you must determine where to install all of the necessary files on the user's machine. You record this information in your Setup.lst file. See "Manually Editing a Setup.lst File" in this chapter for more information on how to record this information in the file.

The files required by your application can be divided into several categories.

Each type of file is best installed in a different location.

Program Files

Program files are files your application must have in order to run and that are useful only in the context of your application — for example, the application's .exe file and its required data files.

Program files should be installed in the application directory that the user specifies during installation. Code in Setup1.vbp demonstrates how to write files to this location. By default, the Setup Toolkit uses the \Program Files directory as the root location to install applications onto Windows 95 or later and Windows NT systems. For example, Setup1 suggests that Project1 be installed in the \Program Files\Project1 directory.

Caution   When installing a file on the user's machine, you should 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.

Shared Application Files

Shared application files are files that can be used by more than one application on the system. For example, several different vendors may ship applications that use the same ActiveX control. If you create an application that uses the control, you should indicate in your installation program that the control's .ocx file is designed to be shared.

Shared files must be installed in a location that allows other applications to access the them. In most cases, this is \Program Files\Common Files for Windows 95, Windows NT 4.0, or later systems.

When an end user uninstalls your application, the system only removes a shared file if there are no other applications that could use the file.

Remote Automation Components

Install Remote Automation server components to the \Windows\System or \Winnt\System32 directory. This ensures that your applications use the most current Remote Automation server components.

Tip   You can use the $(WinSysPath) installation macro to ensure that these files are installed in the correct directory.