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

前端 未结 28 1044
春和景丽
春和景丽 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 22:12

    Outlook Bitness registry key does not exist on my machine.

    One way to determine Outlook Bitness is by examining Outlook.exe, itself and determine if it is 32bit or 64bit.

    Specifically, you can check the [IMAGE_FILE_HEADER.Machine][1] type and this will return a value indicating processor type.

    For an excellent background of this discussion, on reading the PE Header of a file read this (outdated link), which states;

    The IMAGE_NT_HEADERS structure is the primary location where specifics of the PE file are stored. Its offset is given by the e_lfanew field in the IMAGE_DOS_HEADER at the beginning of the file. There are actually two versions of the IMAGE_NT_HEADER structure, one for 32-bit executables and the other for 64-bit versions. The differences are so minor that I'll consider them to be the same for the purposes of this discussion. The only correct, Microsoft-approved way of differentiating between the two formats is via the value of the Magic field in the IMAGE_OPTIONAL_HEADER (described shortly).

    An IMAGE_NT_HEADER is comprised of three fields:

    typedef struct _IMAGE_NT_HEADERS { DWORD Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; } IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32;

    and you can get the c# code here.

    The Magic field is at the start of the IMAGE_OPTIONAL_HEADER structure, 2 bytes at offset 24 from the start of the _IMAGE_NT_HEADERS. It has values of 0x10B for 32-bit and 0x20B for 64-bit.

    0 讨论(0)
  • 2020-11-29 22:12

    Best easy way: Put the ABOUT Icon on your Office 2016 Application. Example Excel

    1) Open Excel -> File -> Options -> Customize Ribbon

    2) You 'll see 2 panes. Choose Commands From & Customize The Ribbon

    3) From Choose Command, Select All Commands

    4) From the resulting List Highlight About (Excel)

    5) From the Customize The Ribbon Pain, Highlight Any Item (ex. View) where you want to put the About icon

    6) Click New group at the bottom

    7) Click the add button located between the two pane. DONE

    Now when you click the View Tab in excel and click about you'll see 32 bit or 64 bit

    0 讨论(0)
  • 2020-11-29 22:13

    I found the way for checking office bitness .

    We can check office 365 and 2016 bitness using this registry key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration
    

    Platform x86 for 32 bit.

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration
    

    Platform x64 for 64 bit.

    Please check...

    0 讨论(0)
  • 2020-11-29 22:14

    I found this approach:

    If HKLM\Software\WOW6432Node exists then Windows is 64-bit.

    If HKLM\Software\WOW6432Node\Microsoft\Office exists, then Office is 32-bit.

    If HKLM\Software\WOW6432Node\Microsoft\Office does not exist, but HKLM\Software\Microsoft\Office does exist, then Office is 64-bit.

    If HKLM\Software\WOW6432Node does not exist, then Windows and Office are 32-bit.

    Source: Technet Forums

    0 讨论(0)
  • 2020-11-29 22:15

    I don't have a key called bitness in either of these folders. I do have a key called "default" in both of these folders and the value is "unset" My computer came with office 2010 starter (I assume 64 bit). I removed it and tried to do a full install of 32 bit office. I keep getting the following message. the file is incompatible, check to see whether you need x86 or x64 version of the program.

    any advice for me?

    0 讨论(0)
  • 2020-11-29 22:16

    To add to vtrz's answer, here's a function I wrote for Inno Setup:

    const
      { Constants for GetBinaryType return values. }
      SCS_32BIT_BINARY = 0;
      SCS_64BIT_BINARY = 6;
      { There are other values that GetBinaryType can return, but we're }
      { not interested in them. }
    
    { Declare Win32 function  }
    function GetBinaryType(lpApplicationName: AnsiString; var lpBinaryType: Integer): Boolean;
    external 'GetBinaryTypeA@kernel32.dll stdcall';
    
    function Is64BitExcelFromRegisteredExe(): Boolean;
    var
      excelPath: String;
      binaryType: Integer;
    begin
      Result := False; { Default value - assume 32-bit unless proven otherwise. }
      { RegQueryStringValue second param is '' to get the (default) value for the key }
      { with no sub-key name, as described at }
      { http://stackoverflow.com/questions/913938/ }
      if IsWin64() and RegQueryStringValue(HKEY_LOCAL_MACHINE,
          'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe',
          '', excelPath) then begin
        { We've got the path to Excel. }
        try
          if GetBinaryType(excelPath, binaryType) then begin
            Result := (binaryType = SCS_64BIT_BINARY);
          end;
        except
          { Ignore - better just to assume it's 32-bit than to let the installation }
          { fail.  This could fail because the GetBinaryType function is not }
          { available.  I understand it's only available in Windows 2000 }
          { Professional onwards. }
        end;
      end;
    end;
    
    0 讨论(0)
提交回复
热议问题