20 May 2012

Creating 64-bit Installs

32-bit applications and install msi packages will run fine under 64-bit versions of Windows (XP Pro x64, Windows 7 64-bit, Windows Server 2003 x64). There are some differences when it comes to application files locations and registry entries and these must be taken into account when creating 32-bit and 64-bit msi install packages that target 64-bit Windows. These differences are discussed in detail in this article.

Files and Folders

64-bit Windows separates application files into 32-bit and 64-bit folders. This is indicated by the presence of 64-bit equivalents of some key folders. The 'Program Files', 'Program Files\Common' and 'Windows\System' folders contain only 64-bit application files. 32-bit applications must install their files into the new 'Program Files (x86)', 'Program Files (x86)\Common' and 'Windows\System32' folders respectively.

Windows Installer introduces the predefined installation folders ProgramFiles64Folder, CommonFiles64Folder and System64Folder. Files that are specified to be installed to these locations are placed in the 64-bit folders on the target machine. The old ProgramFilesFolder, CommonFilesFolder and SystemFolder predefined folders install files into the 32-bit locations on 64-bit Windows.

Files that are to be installed into one of the 64-bit folders must be associated with components that have the 64-bit attribute set, otherwise the installation package will generate Windows Logo validation errors.

Registry

The registry now becomes 64-bit with support for 32-bit applications. 64-bit Windows redirects 32-bit registry access to HKEY_LOCAL_MACHINE to the HKEY_LOCAL_MACHINE\Software\WOW6432node sub-branch. This behaviour is transparent to 32-bit applications. From an installer point of view, adding keys and data to the 64-bit registry is controlled by the presence of the 64-bit attribute of the associated component. If this bit is not set, the registry data is written to the redirected 32-bit branch.

Note: HKEY_CLASSES_ROOT and HKEY_CURRENT_CONFIG are mirrored sub-branches of HKEY_LOCAL_MACHINE.

MSIStudio and 64-bit installs

MSIStudio provides full support for 64-bit msi installs packages. In the File System view, the new 64-bit predefined folders are available. When creating a new project on a 64-bit development system, MSIStudio will display by default the 64-bit installation directories rather than the 32-bit directories.

MSIStudio will also mark the default release as 64-bit. This has the effect of generating components with the 64-bit attribute set by default. 64-bit application files need this attribute set and additionally, registry data will get added to the main 64-bit registry rather than the 32-bit sub-branch.

Mixing 32-bit and 64-bit resources

A single install package can contain both 32-bit and 64-bit files and registry entries simultaneously. Care should be taken to ensure that the 32-bit files are placed into the correct 32-bit Windows predefined folders, and that the components for these files are marked explicitly as 32-bit. This is also true for registry entries that are intended to be written to the 32-bit portion of the Registry.

Mixing 32-bit and 64-bit installs in a single package

Windows Installer will only run 64-bit installation packages on 64-bit Windows. It is a current limitation of Windows Installer that it is not possible to create a single msi install package that can be run on both 32-bit and 64-bit Windows. Separate installs must be created for the different versions of Windows.

MSIStudio allows both 32-bit and 64-bit install packages to be included in a bootstrapper project. The setup that is created from this project can select at run time the appropriate msi install package to extract and run. In this way, application developers need only store a single setup.exe on a website to cover both versions of Windows. See the example tutorial: Creating a single Setup to target both 32-bit and 64-bit Windows.

Additional information:

Heath Stewart Blog: Windows Installer on 64-bit Platforms
Microsoft: About Windows Installer on 64-Bit Operating Systems