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

前端 未结 28 1137
春和景丽
春和景丽 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:07

    Regret to say, but Both Otacku's and @clatonh's methods aren't working for me - neither have Outlook Bitness nor {90140000-0011-0000-1000-0000000FF1CE} in registry (for 64-bit Office without Outlook installed).

    The only way I have found, though, not via the registry, is to check bitness for one of the Office executables with the use of the Windows API function GetBinaryType (since Windows 2000 Professional).

    For example, you can check the bitness of Winword.exe, which path is stored under
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe.

    Here is the MFC code fragment:

    CRegKey rk;
    if (ERROR_SUCCESS == rk.Open(HKEY_LOCAL_MACHINE, 
      "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Winword.exe", 
      KEY_READ)) {
        CString strWinwordPath;
        DWORD dwSize = MAX_PATH;
        if (ERROR_SUCCESS == rk.QueryStringValue(strWinwordPath, 
            strWinwordPath.GetBuffer(MAX_PATH), &dwSize)) {
                strWinwordPath.ReleaseBuffer();
                DWORD dwBinaryType;
                if (::GetBinaryType(strWinwordPath, &dwBinaryType)) {
                    if (SCS_64BIT_BINARY == dwBinaryType) {
                        // Detected 64-bit Office 
                    } else {
                        // Detected 32-bit Office 
                    }
                } else {
                    // Failed
                }
            } else {
                // Failed
            }
        } else {
        // Failed
    }
    

提交回复
热议问题