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

前端 未结 4 1772
Happy的楠姐
Happy的楠姐 2021-01-14 06:01

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 versi

相关标签:
4条回答
  • 2021-01-14 06:07

    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>
    
    0 讨论(0)
  • 2021-01-14 06:07

    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.

    0 讨论(0)
  • 2021-01-14 06:15

    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.

    0 讨论(0)
  • 2021-01-14 06:23

    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.

    0 讨论(0)
提交回复
热议问题