Detect whether MS Office installed is 32bit or 64bit by using registry

本小妞迷上赌 提交于 2019-12-18 06:59:17

问题


I want to install vsto addin based on the excel version (32 bit or 64 bit). I am planning to bundle both 32bit and 64 bit msis and install one by determining the excel version. I am able to find this link to detect whether 2010 office is 32 bit or 64 bit by using registry. Detect whether Office is 32bit or 64bit via the registry But i want to check for excel 2007 and 2013 whether they are 32 bit or 64 bit. Is it possible to detect them via registry.


回答1:


First, look for the installed version of Outlook in this key:

HKEY_CLASSES_ROOT\Outlook.Application\CurVer

The value will be Outlook.Application.15 (for 2013). Then parse that value to get the integer and lookup this key:

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\15.0\Outlook

If it exists, check the value of Bitness to determine if it is 32-bit (x86) or 64-bit (x64). If it doesn't exist, assume 32-bit.




回答2:


Given: Office32 is installed into "Program Files (x86)", this works for me.

I basically check to see if winword.exe is somewhere below the key. If they don't install the word part, well, tough at this point. I use this to variably run 32-bit or 64-bit msi installers for office.

<Fragment>
<Property Id="IS_32BITOFFICE">
  <DirectorySearch Path="[ProgramFilesFolder]\Microsoft Office"                  
                   Depth="4"                   
                   AssignToProperty="no"                   
                   Id="IS_32BIT_OFFICE_DIRSEARCH">
    <FileSearch   Name="winword.exe" />
  </DirectorySearch>
</Property>

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
  <Component Id="WIN64_OFFICE32_MSI">
    <File Id="WIN64_OFFICE32_MSI" src="WIN64_OFFICE32.txt"/>
    <Condition>IS_32BITOFFICE</Condition>
  </Component> 
  <Component Id="WIN64_OFFICE64_MSI">
    <File Id="WIN64_OFFICE64_MSI" src="WIN64_OFFICE64.txt"/>
    <Condition>NOT IS_32BITOFFICE</Condition>
  </Component> 
    </ComponentGroup>
</Fragment>



回答3:


You can use the product code (GUID) to identify the bitness of Office applications. See How to detect whether installed MS Office 2010 is 32 or 64 bit for more information.




回答4:


You can't reliably detect it from registry (direct call). Better is to create Custom installer module in C# or VB.net, fetch ProductCode of application. From product code, you can get the Bitness.

Product code is also fetched from registry, but let Office application handle it.

Private IsExcel32Bit As Boolean = False
Private IsExcel64Bit As Boolean = False
Private ReadOnly STR_prdCodeDelimeter As Char = CChar("-")

Private Sub GetExcelBitness(ByVal exApp As Microsoft.Office.Interop.Excel.Application)
    Dim prdCode As String = exApp.ProductCode
    If Not String.IsNullOrEmpty(prdCode) AndAlso CInt(prdCode.Split(STR_prdCodeDelimeter)(3)(0).ToString) = 0 Then
        IsExcel32Bit = True
    ElseIf Not String.IsNullOrEmpty(prdCode) AndAlso CInt(prdCode.Split(STR_prdCodeDelimeter)(3)(0).ToString) = 1 Then
        IsExcel64Bit = True
    End If
End Sub

Btw keeping both installer separately is going to help you in future. Sometimes product code might be null or wrong if MS Office is not installed properly.



来源:https://stackoverflow.com/questions/27900574/detect-whether-ms-office-installed-is-32bit-or-64bit-by-using-registry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!