使用注册表检测安装的 MS Office 是 32 位还是 64 位
Detect whether MS Office installed is 32bit or 64bit by using registry
我想安装基于 excel 版本(32 位或 64 位)的 vsto 插件。
我计划捆绑 32 位和 64 位 msis,并通过确定 excel 版本来安装一个。
我能够找到这个 link 以使用注册表检测 2010 office 是 32 位还是 64 位。
Detect whether Office is 32bit or 64bit via the registry
但我想检查 excel 2007 和 2013 是 32 位还是 64 位。
是否可以通过注册表检测到它们。
您可以使用产品代码 (GUID) 来识别 Office 应用程序的位数。有关详细信息,请参阅 How to detect whether installed MS Office 2010 is 32 or 64 bit。
您无法从注册表中可靠地检测到它(直接调用)。更好的方法是在 C# 或 VB.net 中创建自定义安装程序模块,获取应用程序的 ProductCode。从产品代码中,您可以得到位数。
产品代码也从注册表中获取,但让 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,有时产品代码可能为空或错误。
首先,在此键中查找已安装的 Outlook 版本:
HKEY_CLASSES_ROOT\Outlook.Application\CurVer
该值将为 Outlook.Application.15(2013 年)。然后解析该值以获取整数并查找此键:
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office.0\Outlook
如果存在,检查Bitness 的值以确定它是32 位(x86) 还是64 位(x64)。如果不存在,则假定为 32 位。
鉴于:Office32 安装到 "Program Files (x86)",这对我有用。
我基本上是检查 winword.exe 是否在键下方的某处。如果他们不安装 word 部分,那么,此时就很难了。我用它可变地 运行 32 位或 64 位 msi 安装程序 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>
我想安装基于 excel 版本(32 位或 64 位)的 vsto 插件。 我计划捆绑 32 位和 64 位 msis,并通过确定 excel 版本来安装一个。 我能够找到这个 link 以使用注册表检测 2010 office 是 32 位还是 64 位。 Detect whether Office is 32bit or 64bit via the registry 但我想检查 excel 2007 和 2013 是 32 位还是 64 位。 是否可以通过注册表检测到它们。
您可以使用产品代码 (GUID) 来识别 Office 应用程序的位数。有关详细信息,请参阅 How to detect whether installed MS Office 2010 is 32 or 64 bit。
您无法从注册表中可靠地检测到它(直接调用)。更好的方法是在 C# 或 VB.net 中创建自定义安装程序模块,获取应用程序的 ProductCode。从产品代码中,您可以得到位数。
产品代码也从注册表中获取,但让 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,有时产品代码可能为空或错误。
首先,在此键中查找已安装的 Outlook 版本:
HKEY_CLASSES_ROOT\Outlook.Application\CurVer
该值将为 Outlook.Application.15(2013 年)。然后解析该值以获取整数并查找此键:
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office.0\Outlook
如果存在,检查Bitness 的值以确定它是32 位(x86) 还是64 位(x64)。如果不存在,则假定为 32 位。
鉴于:Office32 安装到 "Program Files (x86)",这对我有用。
我基本上是检查 winword.exe 是否在键下方的某处。如果他们不安装 word 部分,那么,此时就很难了。我用它可变地 运行 32 位或 64 位 msi 安装程序 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>