共用方式為


Developing Outlook 2010 Solutions for 32-bit and 64-bit Systems

This post captures and summarizes information about developing an Outlook solution for customers who run 32-bit and 64-bit versions of Outlook 2010. Since developing Outlook solutions is a very broad subject, the article gathers information from various sources, and points to some of these locations for further details.

Bitness Compatibility Between Windows and Office 2010

Let’s first talk about the compatibility of the bitness of Windows, Microsoft Office, and Microsoft Outlook. The term “bitness” refers to the distinction between 32-bit and 64-bit processor architectures and the associated compatibility of applications. In this blog, “bitness” is used to qualify the version of Windows, Office, Outlook, or an application built to suit a 32-bit or 64-bit processor architecture of a computer. Each Office 2010 application is available in a 32-bit version and 64-bit version. For Outlook 2010, the bitness of Outlook depends on the bitness of Windows and the bitness of any other Office application that is already installed on that computer. Here are the dependencies:

· On a 32-bit Windows operating system, you can only install 32-bit Office (and 32-bit Outlook).

· On a 64-bit Windows operating system, you can install either 32-bit Office (and 32-bit Outlook), or 64-bit Office (and 64-bit Outlook). The default installation of Office 2010 on 64-bit Windows is 32-bit Office (and 32-bit Outlook).

· If some other Office 2010 application is already installed on a computer, then the bitness of Outlook 2010 that you will install must be consistent. For example, if a 32-bit Excel 2010 is already installed on a computer, you can only install 32-bit Outlook 2010 on that computer. Similarly, if a 64-bit Word 2010 is already installed on a computer, then you can only install 64-bit Outlook 2010.

Default Installation Locations

The following are the default installation locations when you install Office 2010:

· For a computer running 32-bit Windows, typically the location is C:\Program Files\Microsoft Office\Office14\.

· For a computer running 32-bit Office on 64-bit Windows, typically the location is C:\Program Files (x86)\Microsoft Office\Office14\.

· And, for a computer running 64-bit Office, typically the location is C:\Program Files\Microsoft Office\Office14\.

Major Categories of Outlook Solutions

Outlook solutions fall into a few major categories:

· Add-ins written in managed languages (such as C# or Visual Basic), or standalone applications and add-ins written in unmanaged languages (such as C++ or Visual Basic 6.0). Note that Microsoft no longer supports Visual Basic 6.0.

· Macros written in Visual Basic for Applications (VBA).

· Messaging API (MAPI) applications written in typically C++.

The following sections describe the issues that developers of each category of Outlook solutions have to be aware of when planning the availability of their solutions for Outlook 2010.

Managed Add-ins, and Unmanaged Applications and Add-ins for Outlook

Basically, the way to call the Outlook object model remains the same*, regardless of whether the add-ins are going to be run on a 32-bit or 64-bit version of Outlook 2010.

You do not need to recompile existing (32-bit) managed or unmanaged add-ins, if you expect the add-ins to continue to run only on computers with 32-bit Outlook installed.

In particular, for existing managed add-ins, make sure that you have built them using Microsoft Visual Studio Tools for the Microsoft Office system 3.0, or Microsoft Office development tools in Visual Studio 2010, with the Any CPU option for target platform on the Build tab of the Project Properties dialog box. Add-ins built with such settings work for (both 32-bit and) 64-bit versions of Office 2010. If you used other settings, rebuild your managed add-ins using the specified settings so that they will run on computers with either 32-bit or 64-bit Outlook 2010 installed.

Any existing unmanaged, standalone application (in .exe) that runs outside of the Outlook process written for 32-bit Outlook does not require recompilation for 64-bit Outlook, as long as the application interacts with Outlook using the Outlook object model and not MAPI. (For MAPI applications, see the section “MAPI Applications for Outlook” below.) COM manages the marshaling from the 32-bit application to 64-bit Outlook.

However, if you expect any existing unmanaged add-in will be run on computers with 64-bit Outlook 2010, you must recompile the add-in for 64-bit Outlook 2010. To clarify, you will have one version of the add-in to run on 32-bit Outlook, and another version of the add-in to run on 64-bit Outlook. Because there is no 64-bit Visual Basic 6.0 runtime, existing unmanaged add-ins written in Visual Basic 6.0 targeting to run on 64-bit Outlook 2010 should be rewritten, for example, as a managed add-in in Visual Basic.

*Note that even though you make calls the same way if you are targeting an add-in to run on 32-bit Outlook 2010 vs 64-bit Outlook 2010, there are changes in the Outlook 2010 object model such that, if you adapt an existing add-in to use the object model of Outlook 2010, you must be aware of the following:

· Object model calls in previous versions of Outlook were based on the assumption that there was only one Exchange account per profile. This assumption is not correct in Outlook 2010, since there can be multiple Exchange accounts per profile.

· Existing add-ins that modify a command bar or use Application events for shortcut menus may not work as expected in Outlook 2010. Update these add-ins to use the Office Fluent user interface extensibility. For more information, see Extending the User Interface in Outlook 2010.

VBA Macros for Outlook

If you have existing macros written for (32-bit) Outlook, and you intend to allow users to run the macros on 64-bit Outlook 2010, you will have to recompile the macros using Visual Basic for Applications 7.0 (VBA 7), and use conditional compilation to assure backward compatibility as well as compatibility with 64-bit Outlook. You will need to update any Declare statements, as well as address pointers and window handles in user-defined types used by Declare statements. If your macros use any ActiveX controls, these ActiveX controls will have to be updated for 64-bit Outlook as well. For more details, see Compatibility Between the 32-bit and 64-bit Versions of Office 2010.

MAPI Applications for Outlook

If your existing 32-bit MAPI application is going to be running on a computer with 64-bit Outlook installed, you will need to rebuild your 32-bit application as a 64-bit application. Outlook 2010 provides a set of MAPI header files that support MAPI applications to work with both 32-bit and 64-bit Outlook 2010. Make sure you download these header files from Outlook 2010: MAPI Header Files and rebuild your MAPI application using these header files.

In general, the bitness of the MAPI application must be the same as the bitness of the MAPI subsystem on the computer that the application is targeted to run on. The bitness of the MAPI subsystem, in turn, is determined by and always the same as the bitness of the installed version of Outlook. So if you plan to develop a MAPI application that will be run on computers with either a 32-bit or 64-bit version of Outlook 2010 installed, you will need to build two separate versions of the application, one to work with 32-bit Outlook and one to work with 64-bit Outlook.

For more information about MAPI support for 64-bit Outlook, see Building MAPI Applications on 32-Bit and 64-Bit Platforms.

Aside from rebuilding MAPI applications, sometimes it's necessary to check the version of Outlook to ensure that a MAPI application calls API elements that are supported by the currently running version of Outlook.

To learn how to check the version of Outlook and whether the installed version of Outlook is 64-bit Outlook 2010, see How to: Check the Version of Outlook.

Also, to learn how to decipher Outlook version information and the expected values for different parts of a version string for certain released versions of Outlook, see How to determine Outlook version information.

Comments

  • Anonymous
    July 02, 2010
    How is the Windows API called for Outlook 2010 64 bit? I have a SetParent API call which freezes Outlook 2010 64 bit, however it runs fine in 32 bit!