使用注册表检测MS Office是安装的是32位还是64位

时间:2015-01-12 11:06:21

标签: wix registry ms-office vsto add-in

我想基于excel版本(32位或64位)安装vsto addin。 我打算捆绑32位和64位msis,并通过确定excel版本安装一个。 我能够通过使用注册表找到此链接以检测2010办公室是32位还是64位。 Detect whether Office is 32bit or 64bit via the registry 但我想检查excel 2007和2013是否是32位或64位。 是否可以通过注册表检测它们。

4 个答案:

答案 0 :(得分:3)

首先,在此密钥中查找已安装的Outlook版本:

HKEY_CLASSES_ROOT \ Outlook.Application \ CURVER

值为Outlook.Application.15(2013年)。然后解析该值以获取整数并查找此键:

HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \微软\办公室\ 15.0 \ Outlook中

如果存在,请检查Bitness的值以确定它是32位(x86)还是64位(x64)。如果它不存在,则假定为32位。

答案 1 :(得分:3)

鉴于:Office32已安装到“Program Files(x86)”中,这对我有用。

我基本上检查一下winword.exe是否位于键下方。如果他们没有安装单词部分,那么,此时很难。我使用它来可变地运行32位或64位msi安装程序。

<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>

答案 2 :(得分:2)

您可以使用产品代码(GUID)来识别Office应用程序的位数。有关详细信息,请参阅How to detect whether installed MS Office 2010 is 32 or 64 bit

答案 3 :(得分:2)

您无法从注册表(直接呼叫)中可靠地检测到它。更好的是在C#或VB.net中创建自定义安装程序模块,获取应用程序的ProductCode。从产品代码中,您可以获得Bitness。

产品代码也是从注册表中提取的,但让Office应用程序处理它。

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

将两个安装程序分开保存,将来会帮助你。如果未正确安装MS Office,有时产品代码可能为空或错误。

相关问题