Detect whether Office is 32bit or 64bit via the registry

前端 未结 28 1041
春和景丽
春和景丽 2020-11-29 21:29

Now that Office also comes in a 64bit install, where in the registry do you find out if the version of Office installed is 32bit or 64bit?

相关标签:
28条回答
  • 2020-11-29 21:53

    This InnoSetup code is working for me under Win 10x64 and Office 2016 x86 (using 'HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration' and key 'Platform')

    [Code]
    const
      RegOffice='SOFTWARE\Microsoft\Office\ClickToRun\Configuration';
      RegOfficeKey='Platform';
    
    /// <summary>
    /// Get current HKLM version
    /// </summary>
    function GetHKLM: Integer;
    begin
      if IsWin64 then
        Result := HKLM64
      else
        Result := HKLM32;
    end;
    
    /// <summary>
    /// Check is Microsoft Office is installed or not
    /// </summary>
    function IsOfficeInstalled (): Boolean;
    var
      platform: string;
    begin
      RegQueryStringValue(GetHKLM(), RegOffice, RegOfficeKey, platform);
      if platform = 'x86' then begin
       SuppressibleMsgBox('Microsoft Office found (x86 version)' , mbConfirmation, MB_YESNO or MB_DEFBUTTON1, IDYES);
        Result := True;
      end else if platform = 'x64' then begin
        SuppressibleMsgBox('Microsoft Office found (x64 version)', mbConfirmation, MB_YESNO or MB_DEFBUTTON1, IDYES);
        Result := True;
      end else begin
        SuppressibleMsgBox('Microsoft Office NOT found' + platform + '.', mbConfirmation, MB_YESNO or MB_DEFBUTTON1, IDYES);
        Result := False;
      end;
    end;
    
    0 讨论(0)
  • 2020-11-29 21:56

    From TechNet article on 64-bit editions of Office 2010:

    If you have installed Office 2010 including Microsoft Outlook 2010, Outlook sets a registry key named Bitness of type REG_SZ on the computer on which it is installed. The Bitness registry key indicates whether the Outlook 2010 installation is 32-bit or 64-bit. This may be useful to administrators who are interested in auditing computers to determine the installed versions of Office 2010 in their organization.

    • Registry path: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\14.0\Outlook
    • if you have installed Office 2013 then use this Registry path: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0\Outlook
    • Registry key: Bitness
    • Value: either x86 or x64

    and elsewhere in the same article:

    Starting with Office 2010, Outlook is available as a 32-bit application and a 64-bit application. The version (bitness) of Outlook that you choose depends on the edition of the Windows operating system (32-bit or 64-bit) and the edition of Office 2010 (32- or 64-bit) that is installed on the computer, if Office is already installed on that computer.

    Factors that determine the feasibility of installing a 32-bit or a 64-bit version of Outlook include the following:

    • You can install 32-bit Office 2010 and 32-bit Microsoft Outlook 2010 on a supported 32-bit or 64-bit edition of the Windows operating system. You can install the 64-bit version of Office 2010 and 64-bit Outlook 2010 only on a supported 64-bit operating system.
    • The default installation of Office 2010 on a 64-bit edition of the Windows operating system is 32-bit Office 2010.
    • The bitness of an installed version of Outlook is always the same as the bitness of Office 2010, if Office is installed on the same computer. That is, a 32-bit version of Outlook 2010 cannot be installed on the same computer on which 64-bit versions of other Office 2010 applications are already installed, such as 64-bit Microsoft Word 2010 or 64-bit Microsoft Excel 2010. Similarly, a 64-bit version of Outlook 2010 cannot be installed on the same computer on which 32-bit versions of other Office applications are already installed.
    0 讨论(0)
  • 2020-11-29 21:56

    Search the registry for the install path of the office component you are interested in, e.g. for Excel 2010 look in SOFTWARE(Wow6432Node)\Microsoft\Office\14.0\Excel\InstallRoot. It will only be either in the 32-bit registry or the 64-bit registry not both.

    0 讨论(0)
  • 2020-11-29 21:57

    You can search the registry for {90140000-0011-0000-0000-0000000FF1CE}. If the bold numbers start with 0 its x86, 1 is x64

    For me it was in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Registration{90140000-0057-0000-0000-0000000FF1CE}

    Source

    0 讨论(0)
  • 2020-11-29 21:58

    I have win 7 64 bit + Excel 2010 32 bit. The registry is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Registration{90140000-002A-0000-1000-0000000FF1CE}

    So this can tell bitness of OS, not bitness of Office

    0 讨论(0)
  • 2020-11-29 21:58

    I've found a much easier way. Using Powershell, we can hook Excel as a COM object.

    $user = $env:UserName
    $msoExcel = New-Object -ComObject Excel.Application  
    $msoExcel | Select-Object -Property OperatingSystem | Out-File "\\SERVER\Path\To\Dump\msoVersion-$user.txt"
    exit
    

    When requesting the OperatingSystem this way, we get strange results, have a look here. PC3 is mine.

    I hope this works for you guys. Sorry for the lack of code; my scripts are mostly functional.

    Edit: Don't forget to add the code to close Excel after you're done retrieving the data.
    After testing this code yesterday I had tons of Excel opening and crashing all of a sudden..
    This will make sure you'll keep users and admins happy (:

    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($msoExcel)
    Remove-Variable msoExcel
    
    0 讨论(0)
提交回复
热议问题