How to detect MS Office x86 vs x64.

Started by Daniel, August 18, 2014, 01:52:04 AM

Previous topic - Next topic

Daniel

Hi there,

I would like to reliably detect the versions of MS Office 2010 and 2013 for the x86 vs x64 installation.

If one looks in HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\ there is evidence of 64-bit components even on a 32 bit version.

Daniel

stanl

Possibly check

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\version\Outlook

which would return 14.0 for 32bit; 15.0 for 64bit. (as posted on StackOverflow).

td

The key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook" has a value called 'Bitness' on my system. The value of the Value is 'X86' on the system I checked indicating that office 14.0 is 32-bit.

Code (winbatch) Select

strBitness = RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\Office\14.0\Outlook[Bitness]")
Message("Office 10 Bitness", strBitness)
 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

Daniel

Hi Guys.

Thanks for your feedback.

I did find the Bitness value yesterday based on Stanl's reply.

What I also found previously is that version 14.0 is Office 2010, and 15.0 is Office 2013.

In fact it appears that the Bitness for 14.0 is removed during the Office 2013 installation.

Daniel

stanl

Quote from: Daniel on August 19, 2014, 01:11:17 AM
In fact it appears that the Bitness for 14.0 is removed during the Office 2013 installation.
Daniel

Yes, I have both 2010 and 2013 (32bit) installed. You cannot have two versions of Outlook so the Outlook entry is removed for 14.0.  I guess the question remains as to whether the reg key can detect 64bit.

td

Well, there is always the direct approach...
Code (winbatch) Select

;; Calls the GetBinaryType API function
;; accepting an executable file as a parameter.
#DefineFunction GetBinType(strAppPathName)
   nReturn = -1
   hBinType = BinaryAlloc(4)   
   if ( DllCall("Kernel32.dll",long:"GetBinaryTypeA", lpstr:strAppPathName, lpbinary:hBinType) )
      nReturn = BinaryPeek4(hBinType, 0)

   endif
   BinaryFree(hBinType)
   return nReturn
#EndFunction

;; Get the bitness of notepad and convert to a string.
nType = GetBinType(FileLocate("notepad.exe"))
switch nType
   case 0
      strBitness = "32-bit"
      break
   case 6
      strBitness = "64-bit"
      break
   case -1
      strBitness = "Error"
      break
   case 2
      strBitness = "16-bit"
   case nType
      strBitness = "Whatever"
endswitch

Message("Exe Type", strBitness)


Of course the simplest solution might be to simple check for one or more of the Office executables in either the "Program Files" or "Program Files (x86)" directory, assuming default installation directories.  While the Office dlls might exist in both folders, generally the main exes only exist in "Program Files (x86)" on 32-bit installation.  (Despite documentation to the contrary, it is possible to install both 32-bit and 64-bit full versions on the same system.  However, this does have issues and is not common.)
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade