Determine if a Processor is AMD64 or Intel64?

inno-setup, visual-c++, wix

Solution

You can use the `Win32_Processor` WMi class, from Inno setup you can execute a WMI query without problems. Check this sample:

var
  FSWbemLocator : Variant;
  FWMIService   : Variant;
  FWbemObject   : Variant;
begin
FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
FWMIService   := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
FWbemObject   := FWMIService.Get('Win32_Processor');
if FWbemObject.Architecture=9 then //is a 64 bits processor
  if  FWbemObject.Family=131 then  //all 64-bit AMD processors are identified by using a Family attribute value of 0x83 (131).

From here you can use the Architecture, Family, Manufacturer and other properties to determine the processor type.

Problem

The Visual Studio C++ compiler provides the command line compiler options `/favor:AMD64` and `/favor:INTEL64` to optimize for AMD64 or Intel64 processors respectively. Now, the terms AMD64 and Intel64 are essentially interchangeable for most purposes, but there are some differences that the compiler can optimise for. On Microsoft Windows 7, is there a reliable way to check at application install time whether we're installing on an AMD64 or INTEL64 system? I'm using InnoSetup and WiX for installers, and I'm speculating about selecting the version to install based on AMD64 or INTEL64 CPU. Edit: Some notes in retrospect In the end, the answers from RRUZ and Andrew Cooper both gave good solid strategies for approaching this issue, but as neither of them are really firmly future proof, personally I'm going to stick with the default `/favor:blend` for my project.

Original source