In-Depth

The Odd Couple

Can older applications and Windows XP share a network without driving each other crazy?

With extended support for Windows NT 4.0 on its last legs, many companies will be faced with the task of upgrading to Windows 2000 or Windows Server 2003. When that happens, it’s also quite natural to do a desktop upgrade. As the transition from current desktop platforms to Windows XP progresses, application compatibility will be a primary concern.

The importance of the ability to run older applications on XP can’t be overstated. The cost of upgrading to a new OS is significant, but the added cost of purchasing upgraded software applications can be enough to delay an upgrade. Additionally, applications that run on desktops and servers are ultimately used to generate revenue for a company. Your company loses revenue when an application it depends upon can’t run.

To combat these issues, Microsoft has developed tools and technologies to run older applications on XP. In this article, we’ll explore the application-compatibility technologies found in XP and the Application Compatibility Toolkit 3.0, which can help older apps get along with XP. I explain what kinds of application incompatibilities you’ll run across and show you how to create and deploy compatibility fixes throughout the enterprise.

Common Compatibility Issues
Programs that ran under Windows 9x or even NT may not run—or may have problems running—under XP. It enforces programming rules and uses resources more efficiently; as a result , XP causes problems for applications written for earlier versions of Windows, which don’t enforce the same rules.

One of the most common causes of application incompatibility is when an application encounters a new Windows version number and, as a result, won’t install or run. Each version of Windows has a version number. For example, the version number for XP is five. But if the application’s tricked into seeing the Windows version number it expects, it may run just fine on the new OS.

Other common compatibility issues include:

 Path changes made for user profile, My Documents, and temporary directories, which cause problems for applications expecting user information in a specific location.

 Applications that call older versions of Win32 API functions, which return unexpected values. For example, under Windows 9x, a call may be made to the GetDiskFreeSpace API to find out how much space is available on a hard disk. If a value greater than 2GB is returned, an application may fail to install.

 Users with limited user access, such as members of a local Users security group who don’t have administrative privileges, may encounter many compatibility issues for applications written for Windows 9x. Windows 9x doesn’t have user-based security—every user has full access to the Registry and the Program Files folder and can make system-wide changes. However, when a limited user account attempts to install or run an application written for Windows 9x on XP, the applications will usually be denied access to HKEY_LOCAL_MACHINE and to the Program Files folder. As a result, they’ll fail to install or run.

Compatibility Solutions
Now we know some of the compatibility problems. What are the solutions? XP introduces three levels of native compatibility solutions:

 Compatibility fix: This option provides a “shim.” A shim is a dynamic link library (DLL) used to fix a single compatibility issue. The DLL is dynamically loaded when the application starts. It replaces function calls with one the application expects. For example, a compatibility fix can be applied to trick an application into thinking it’s running on an earlier version of Windows.

 Compatibility mode: This is a collection of compatibility fixes applied together. For example, for XP to respond to an application with Windows 95-like behavior, a Windows 95 compatibility layer can be applied to an application. This particular compatibility mode is comprised of 57 individual fixes.

 AppHelp: If a compatibility fix or mode can’t resolve a compatibility issue with an application, a message can be displayed advising the user of unresolved compatibility issues or block an application from running.

These compatibility solutions use matching information found in databases to identify an application. They then inform the compatibility technologies as to which solution or solutions should be applied to an application. There are several database files used by the compatibility fix technologies. The two you should be familiar with are:

 SYSMAIN.SDB: This database contains a list of many third-party applications and their associated compatibility modes and compatibility fixes.

 APPHELP.SDB: This database contains a list of third-party applications and their associated help messages.

These databases are located in the %windir%\apppatch directory. There are several methods available to apply compatibility fixes and modes found in the compatibility databases.

Applying Compatibility Modes
Compatibility modes can be applied to all computers in the enterprise or individually by the user. A compatibility mode can be applied in one of two methods: First, it can be applied from the property sheet of an application. To use this method, right-click the legacy application executable, select Properties then select the Compatibility tab, shown in Figure 1.

The Compatibility tab in XP
Figure 1. The Compatibility tab is used to enable various compatibility modes and display settings.

The Compatibility mode is used to choose an OS on which the executable ran without problems. The XP options are Windows 95, Windows 98/Me, Windows NT 4.0 SP 5 and Win2K. The Display settings options allow the user to apply changes to color depth, screen resolution and XP themes. These options may be needed to run games and educational applications on XP.

Once a Compatibility mode is applied to an executable, it’s in effect every time the executable is run until either the mode is disabled or the application is reinstalled.

A more user-friendly approach for applying a compatibility mode is through the Program Compatibility Wizard (see Figure 2). To open it, select Start | All Programs | Accessories | Program Compatibility Wizard.

XP's Compatibility Wizard
Figure 2. The Program Compatibility Wizard is available through XP’s Help and Support Center. (Click image to view larger version.)

The wizard guides the user through selecting an application and applying a compatibility mode and display settings to it. Both the Compatibility tab and the Program Compatibility Wizard look to the SYSMAIN.SDB database to apply the compatibility “layers,” which emulate an older version of Windows.

Note: Do not apply compatibility modes to programs such as antivirus, backup, VPN, firewall and disk utilities that use kernel-mode drivers. Doing so can cause the computer to crash. These types of applications have to be upgraded to a newer version compatible with XP.

The Compatibility tab and Program Compatibility Wizard are handy methods of resolving common compatibility issues at the desktop. However, to resolve more complex compatibility issues and deploy the fixes to all computers in a network, something else is needed to get the job done: the Application Compatibility Toolkit.

Application Compatibility Toolkit
The Application Compatibility Toolkit (ACT) contains several tools that assist in testing and fixing application compatibility problems. At the time of this writing, the most recent version of the unified toolkit is 3.0. An earlier version of this toolkit (2.0) is included on the XP CD. Several updates have been made to the tools within ACT 3.0 that improve functionality.

To download ACT 3.0 go to: http://msdn.microsoft.com/library/ default.asp?url=/nhp/Default.asp? contentid=28000911.

The following tools are included within ACT 3.0:

 Application Verifier (AppVerifier): This is used primarily by developers to find compatibility issues in an application such as heap corruption, security vulnerabilities and Registry usage.

 Page Heap (PageHeap): This command-line tool finds heap-related bugs and corruption, aiding in the detection of memory leaks in applications running on XP.

 Microsoft Application Compatibility Analyzer (Analyzer and Collector): This is a combination of two tools used to create a centralized inventory of installed applications for computers on your network and to check the compatibility of the applications against an online database.

 Compatibility Administration Tool (CompatAdmin): This is the ACT’s bread-and-butter tool, and is discussed more fully in the next section.

CompatAdmin
You can use CompatAdmin to view a list of all third-party applications with pre-applied compatibility fixes; view predefined compatibility fixes; view compatibility modes; and view, create, and install custom compatibility fix databases on a computer.

However, the main purpose of CompatAdmin is to apply various compatibility modes or fixes one at a time, then run the application in a test mode within CompatAdmin until finding the right combination of fixes that successfully allows the application to run without errors.

Once you’ve discovered the secret sauce that makes an application run, those fixes can be saved for one or more applications in a custom database. Then, you place the database in a shared folder on the network and install it to all required computers by way of a logon script. Easy stuff, right? No? Let’s step through this process and see how the magic works. First, download and install the ACT. Figure 3 displays CompatAdmin in action.

The Compatibility Administration Tool
Figure 3. Use the Compatibility Administration Tool to create custom fix databases for enterprise deployment. (Click image to view larger version.)

To create a custom database using CompatAdmin:

1. Open CompatAdmin by selecting Start | All Programs | Microsoft Windows Application Compatibility Toolkit | Compatibility Administration Tool 3.0.

2. In the left-hand pane, expand Custom Databases and select “New, untitled” database.

3. Right-click the untitled database, select “Create New” and then select “Application Fix.” The “Create a New Application Fix” dialog box is displayed.

4. In the first field enter the name of the application to be fixed.

5. In the third field, type the path or browse to the executable to which the compatibility fix will be applied. Click Next.

6. Select a compatibility mode or choose None. Click Next.

7. Select the desired compatibility fix or fixes and click on the Test Run button to see if the fixes resolve the compatibility problem. Repeat as many times as necessary. Click Next. The “Matching Information” dialog box is displayed.

8. Click the “Add File” button to select files that will uniquely identify the selected file. Select files associated with the application and installed in the same location as the executable. For example, choose an .hlp file that resides in the same directory as the .exe file. Click Finish.

9. On the menu bar select File, then select Save As.

10. Type a name for the custom database and click OK. The Save Database dialog box is displayed.

11. Select a location for which to save the database, type the name of the database and click Save.

Last, the custom database must be installed on all computers that need the compatibility fixes to run the affected applications. This can be achieved in one of two ways. The first method is to install the ACT on every computer on the network and use CompatAdmin to install the custom database. The second and more practical method is to place the custom database in a shared folder on your network and use the Compatibility Database Installer (SDBINST.EXE) to install and register the compatibility fix database on the target computers via a logon script.

To deploy the custom database .SDB file, place it in a shared folder on your network, then create a logon script with the following syntax to install and register the database automatically: Sdbinst\\servername\sharename\custom database.sdb -q (the -q switch is used to run the installer in quiet mode so messages aren’t displayed).

Remove the logon script once the custom database has been installed on all target computers; if not, the next time the script runs, it’ll detect the installed database and ask if it should be replaced. Also, a compatibility database can only be installed by a user with administrative privileges on the computer. This rule applies when using either CompatAdmin or the SDBINST.EXE command to install a custom database.

Enjoy Your Big, Fat Raise
Once the database has been installed, it’ll be checked for compatibility information every time an application is launched, and management will give you a huge raise in pay because you just saved them the cost of upgrading several applications for all the computers in your company.

Featured