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

前端 未结 28 1092
春和景丽
春和景丽 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条回答
  •  萌比男神i
    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';
    
    /// 
    /// Get current HKLM version
    /// 
    function GetHKLM: Integer;
    begin
      if IsWin64 then
        Result := HKLM64
      else
        Result := HKLM32;
    end;
    
    /// 
    /// Check is Microsoft Office is installed or not
    /// 
    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;
    

提交回复
热议问题