Redistributing Microsoft Visual C++ 6.0 Applications

 

David Schwartz
Microsoft Corporation

May 1999
Revised: August 2000 (updated Dependency Walker downloads)

Summary: Discusses how to get your Microsoft® Visual C++® version 6.0 application to run on any computer running a Microsoft 32-bit operating system. (7 printed pages) Includes a discussion on general redistribution procedures that will help you determine the dependencies of any Visual 6.0 application. Covers:

Introduction

When you develop an application using the Visual C++® 6.0 development system, you have the advantage of working on a computer that is not only a good development environment, but is also an ideal environment on which to run and test applications. However, if a target computer does not have Visual C++ 6.0 installed, you can anticipate that a Visual C++ 6.0 application will not run because it is missing one or more files needed to support the application.

This article discusses how to get your Visual C++ 6.0 application running on any computer running a Microsoft 32-bit operating system. In addition to discussing redistribution scenarios for specific Visual C++ application types, this article also discusses general redistribution procedures that will help you determine the dependencies of any Visual C++ 6.0 application.

A List of Redistributable Files

For a list of files that are redistributable in Visual C++ 6.0, see Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs. Eula.txt, located in the root folder of Disc 1, also contains information on redistributing files, including the definition of the category names from Redist.txt.

Visual C++ Setup may install some redistributable files in your Microsoft Windows® operating system folder. When you redistribute any of these files, you should copy them from the Visual C++ 6.0 product CDs to your own distribution disk image, rather than from your hard disk, to make sure you are redistributing the correct version of the files.

Note that debug versions of an application are not redistributable and that none of the debug versions of various Visual C++ dynamic-link libraries (DLLs) are redistributable.

For more information on Microsoft Visual C++ run-time files and operating system components that are required by most projects created with Visual C++ 6.0, see Knowledge Base article Q259403, Vcredist.exe Installs the Latest Run-Time Components for Visual C++ Applications.

Version Checking of Redistributable Files

It is important to install a newer version of a file and not an older one. For example, you will want to install a newer version of a system DLL on top of an older version, but not an older version on top of a newer version. Typically, version checking is the responsibility of the Setup program. Microsoft Visual C++ 6.0 (except the Standard Edition) and Microsoft Visual Studio 6.0 ship a version of InstallShield that you can use to develop Setup programs.

If you write your own custom Setup program, you must manually check the version when installing redistributable files. At the top of this article, you will find a link to a sample that checks for version numbers or, if version numbers are missing from a file, timestamps.

The programmatic technique for version checking varies, depending on which category of file you are redistributing:

  • For Microsoft Foundation Classes (MFC) DLLs, use the version-checking APIs available as a standard part of the Platform SDK.
  • For ODBC files, see "Installing and Configuring ODBC Software" and "Configuring Data Sources" in the ODBC Programmer's Reference.

You can find information about the version-checking APIs and the ODBC Programmer's Reference in the MSDN Library.

Determining Which DLLs to Redistribute

You can see which DLLs are dependencies of an application by opening the application using the Dependency Walker (Depends.exe). Visual C++ 6.0 shipped with version 1 of this utility, but at the top of this article, you will find links (Alpha and x86) to the latest version of the Dependency Walker.

By using Depends.exe or the DUMPBIN utility with the /DEPENDENTS option, you can see a list of DLLs that statically link to your application and a list of the application's delay-loaded DLLs.

To see which DLLs, such as Microsoft ActiveX® controls, are dynamically loaded, use the profiling feature of Depends.exe. Then, use the application until you are sure that all paths were exercised. When you end the profiling session, Depends.exe will show you which DLLs were dynamically loaded.

As you use DUMPBIN or Depends.exe to view your dependencies, use the file list in Redist.txt to see which Microsoft-supplied DLLs are redistributable.

When using Depends.exe, be aware that a DLL may have a dependency on another DLL or on a version of a specific DLL. You can use Depends.exe on either the development computer or on a target computer. On the development computer, Depends.exe will report the DLLs that are required to support an application. If you have trouble getting an application to run on a target computer, you can copy Depends.exe (and its required DLL) to the target computer and open the application in Depends.exe. Depends.exe will report which of the application's DLLs are either missing or present with an incorrect version.

When you copy a DLL to another machine, copy the DLL such that it replaces the existing DLL. For example, on a Microsoft Windows NT® machine, the system DLLs are located in the system32 directory.

Redistributing Visual C++ ActiveX Controls

Visual C++ 6.0 supplies ActiveX controls you can use in applications that you then redistribute. For a list of the redistributable Visual C++-supplied ActiveX controls, see Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs; any .ocx files in the Os\System folder are redistributable. When you are in the Visual C++ Components and Controls Gallery, highlighting a control will display its .ocx file.

When distributing applications, you must install and register (using Regsvr32.exe) the .ocx for the ActiveX control. In addition, you should make sure the target computer has current versions of the following system files (an asterisk indicates the file needs to be registered):

  • Oleaut32.dll *
  • Olepro32.dll *
  • Stdole2.tlb
  • Asycfilt.dll
  • Comcat.dll *

You can run Vbrun60.exe to update the target computer with the Visual Studio 6.0 versions of these system files. To get the version of Vbrun60.exe with the most up-to-date files for Visual Studio 6.0, see http://search.microsoft.com/us/dev/default.asp and search for Vbrun60.exe from the downloadable files. Be aware that when you run Vbrun60.exe, Msvbvm60.dll is also installed and registered. However, this file is not required to run Visual C++ applications; you can unregister and delete it. Further, if you are going to run Dcom98 (discussed next), you will get updated system files and do not need to also run Vbrun60.exe.

If your application uses one of the ActiveX controls that connects to a database:

  • You need to run DCom98.exe on any Windows 95 or Windows 98 computer. DCom98.exe is in the Dcom98 folder located on Disc 1 of the Visual C++ 6.0 product CDs.
  • You should run Mdac_typ.exe on the target computer to install the Microsoft Data Access SDK. Mdac_typ.exe is in the Mdac2 folder of Disc 2 of the Visual C++ products CDs (Enterprise Edition only). You can also download Mdac_typ.exe from the Universal Data Access Web site at www.microsoft.com/data/.

When using an ActiveX control that connects to a database, you will also need to replicate the data source name on the target computer. You can do this programmatically with functions such as ConfigDSN.

Some redistributable ActiveX controls have additional dependencies. For each .ocx file in the Visual C++ Os\System folder, there is also a .dep file. For each .ocx file that you want to redistribute, look for one or more USES entries in the corresponding .dep file. If a file is listed that is not included in Vbrun60.exe, you must ensure the file will be on the target computer. Any DLLs directly supporting an .ocx file need to be registered. (For Regsvr32.exe to succeed, the target computer must first contain all the DLLs the control statically loads.) Further, if a DLL that is listed as a dependency also has a .dep file in the Os\System folder, you must also investigate that .dep file for USES entries.

Visual Studio Licensed Controls: Visual Studio licensees can redistribute the additional ActiveX controls specific to Visual Studio's other development tools. For example, the Chart control is distributed with Visual Basic, which also ships in Visual Studio. Thus, if you are using Visual C++ as a part of a Visual Studio license, you can redistribute the Chart control. However, if you purchased only Visual C++, you will not have a license to redistribute it.

Redistributing Database Support Files

This section discusses how to redistribute support files for Data Access Objects (DAO) and the database technologies found in the Microsoft Data Access SDK.

Installing DAO Support Files

You can install the necessary files to support a DAO application in one of two ways:

  • Use the Redist version of DAO, which is found in Daosdk\Redist on Disc 1 of the Visual C++ 6.0 product CDs. The Setup file, which is in Daosdk\Redist\Disk1, installs the necessary files to support a DAO application.
  • Hand-install the necessary DAO support files. You can find information about which files need to be installed and registered in the file Daosetup.rtf. Daosetup.rtf is installed when you install the full version of the DAO SDK. See Daosdk\Retail\Disk1 for the Setup file to install the DAO SDK. This version of DAO not only supports DAO running on a computer, but also gives you the necessary support to develop a DAO application.

To install the DAO SDK, the target computer needs current system files. Therefore, you may need to first run Vbrun60.exe or Dcom98.exe. See the section "Redistributing Visual C++ ActiveX Controls" earlier in this article for more information on Dcom98.exe and Vbrun60.exe.

Installing Microsoft Data Access SDK Support Files

You should use Mdac_typ.exe to install support for ODBC, OLE DB, ActiveX Data Objects (ADO), and Remote Data Services (RDS). Mdac_typ.exe is in the Mdac2 folder of Disc 2 of the Visual C++ 6.0 product CDs (Enterprise Edition only). You can also download Mdac_typ.exe from the Universal Data Access Web site at www.microsoft.com/data/.

You can do silent installations by using MDAC_TYP /Q.

On Windows 95 and Windows 98 computers, you should also install Dcom98.exe or Vbrun60.exe to get the latest system files. See the section "Redistributing Visual C++ ActiveX Controls" earlier in this article for more information on Dcom98.exe and Vbrun60.exe.

For other information about using MDAC_TYP, see the following Knowledge Base articles:

  • Q167523: HOWTO: Redistributing DAO with Your Visual C++ 5.0 Application
  • Q177913: HOWTO: Use the MDAC Standalone Setup EXE in Unattended Mode
  • Q181126: INFO: Redistribution for MDAC 1.5 Components Available
  • Q192009: HOWTO: Invoke Silent MDAC or DA SDK 2.0 Redistribution

Look for additional Knowledge Base articles from Microsoft at http://search.microsoft.com/us/dev/default.asp.

Redistributing Web Applications

If your application uses the MFC classes implementing the WebBrowser control (for example, CHtmlView or CHtmlEditView), Microsoft Internet Explorer 4.0 or later must at least be minimally installed on the target computer.

Installing Internet Explorer will also ensure the target computer has the latest common control files.

Information about installing minimal Internet Explorer components is available in the following Knowledge Base article:

  • Q185375: HOWTO: Create a Single EXE Install of Internet Explorer 4

Redistributing MFC, ATL, and OLE DB Templates Applications

Mfc42.dll needs to be redistributed with MFC applications unless you statically linked to the MFC DLL (that is, unless you specified Use MFC in a Static Library on the General tab in the Project Settings dialog box). Note that static linking to MFC is supported only in Visual C++ Professional and Enterprise Editions.

If you dynamically link your application to the MFC library, you will, at a minimum, need to redistribute Mfc42.dll and Msvcrt.dll. All MFC DLLs use the shared version of the C run-time library; thus, Msvcrt.dll is required. If your application uses the MFC database classes, such as CRecordset and CRecordView, you will need to redistribute ODBC and any ODBC drivers that your application uses. (See the section "Redistributing Database Support Files" earlier in this article for more information.)

Mfc42.dll should be registered on the target computer to ensure all MFC functionality is present.

If you redistribute an MFC DLL, be sure you distribute the retail version rather than the debug version. Debug versions of the DLLs are not redistributable. Debug versions of the MFC DLLs have a trailing "d" in their file names, such as in Mfc42d.dll.

If you modify MFC in any way, you must rename the modified MFC DLL so it will not conflict with the MFC DLL that might be installed by other MFC applications on the target computer. Rebuilding and renaming the MFC DLL is not a recommended procedure. For more information, see MFC Technical Note 33 (available in the Visual C++ documentation in the Microsoft Foundation Class Library reference section of the MSDN Library).

An Active Template Library (ATL) or OLE DB Templates project can be built for a MinDependency or a MinSize configuration. MinSize makes the output file as small as possible but requires that Atl.dll to be on the target computer. Atl.dll should be registered on the target computer to ensure all ATL functionality is present. Be aware that the ANSI and Unicode versions of the ATL DLL have the same name: Atl.dll. You cannot redistribute the Unicode version on a Windows 95 or Windows 98 computer; you need the ANSI version (in the Os\System\Ansi folder).

If you build your ATL or OLE DB Templates project for a MinDependency target, you do not need to install and register Atl.dll on the target computer, although you may get a larger program image.

If you redistribute an ATL executable application, you must register the .exe file (and any controls inside it) by issuing the following command:

filename**/regserver**

where filename is the name of the executable file.

For OLE DB Templates applications, ensure the target computer has the latest versions of Microsoft Data Access Components (MDAC) files. For Windows 95 and Windows 98 computers, that also means installing Dcom98. See the section "Redistributing Visual C++ ActiveX Controls" earlier in this article for more information on installing MDAC and Dcom98.

Redistributing Common Controls

Visual C++ 6.0 supports the use of the Window's common controls (Comctl32.dll) that are supplied with Internet Explorer 4.01. This version of Comctl32.dll has new controls, such that the Internet Explorer 4.01 version of Comctl32.dll will have to be on a target machine to ensure that your application will run properly. This is especially true if you use one of the new controls, such as the Date Time Picker.

You can install a version of Comctl32.dll that is compatible with Visual C++ 6.0 applications by accessing the Knowledge Base article Q186176: INFO: Redistribution of Comctl32.dll. Then, follow the Common Control Library Patch link. From the download page, right click the link to download 401comupd.exe.

Installation of Localized MFC Components

If you choose to localize your application's use of the MFC resources by installing an MFC 4.2 localization DLL, you must follow the instructions in this section. Like other shared DLLs, an MFC localization DLL should be installed only if its version is newer than the version that is already installed; therefore, installing this DLL is similar to installing the other DLL(s). See the section "Version Checking of Redistributable Files" earlier in this article.

There are several MFC DLLs supplied for various locales. For example, Mfc42deu.dll is the German version and contains version information that identifies it as German locale. If you install any locale DLL, you must ensure the locale for which the DLL is intended matches the locale of the installed Windows system. When you install the DLL, you must rename it to Mfc42loc.dll.

You should never install an Mfc42loc.dll on an English system. English resources are built into Mfc42.dll, and it is faster to load them from that DLL instead of searching (and loading) an MFC localization DLL first.

See MFC Technical Note 57 (available in the Visual C++ documentation in the Microsoft Foundation Class Library reference section of the MSDN Library) for more information on localizing MFC applications.

If you use an ActiveX control that depends on Msstkprp.dll (typically they will be ATL-based controls) and if you want to ship a localized version of the ActiveX control, you can find a localized version of Msstkprp.dll at https://msdn.microsoft.com/vbasic/downloads/tools/ipdk.aspx.

Thank you

I'd like to thank the following people for their contributions of encouragement and technical guidance to this article: Shaun Miller, Rich McKinnon, Steve Miller, Dave Waggoner, and Rod Wilkinson.