现在Office也可以使用64位安装,那么在注册表中,你应该去哪里查找已安装的Office是32位还是64位版本呢?
现在Office也可以使用64位安装,那么在注册表中,你应该去哪里查找已安装的Office是32位还是64位版本呢?
根据TechNet关于Office 2010的64位版本文章:
如果您已安装了包括Microsoft Outlook 2010在内的Office 2010,Outlook会在安装它的计算机上设置一个名为Bitness的注册表键,类型为REG_SZ。 Bitness注册表键指示Outlook 2010安装是32位还是64位。这对于有兴趣审核计算机以确定其组织中安装的Office 2010版本的管理员可能会有用。
- 注册表路径: HKEY_LOCAL_MACHINE\Software\Microsoft\Office\14.0\Outlook
- 如果您已安装Office 2013,则使用此注册表路径:HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0\Outlook
- 注册表键: Bitness
- 值: 要么为x86或x64
同一篇文章的其他地方:
从Office 2010开始,Outlook可以作为32位应用程序和64位应用程序提供。您选择的Outlook版本(位数)取决于Windows操作系统(32位或64位)的版本以及计算机上已安装的Office 2010版本(32位或64位),如果该计算机上已安装了Office。
确定安装32位或64位Outlook版本的因素包括以下内容:
- 您可以在支持的32位或64位Windows操作系统上安装32位Office 2010和32位Microsoft Outlook 2010。仅在支持的64位操作系统上才能安装Office 2010的64位版本和64位Outlook 2010。
- 在64位Windows操作系统上默认安装32位Office 2010。
- 如果在同一台计算机上已经安装了其他Office 2010应用程序的64位版本,如64位Microsoft Word 2010或64位Microsoft Excel 2010,则安装的Outlook版本的位数始终与Office 2010的位数相同。因此,不可以在已经安装了其他Office应用程序的32位版本的同一台计算机上安装32位版本的Outlook 2010,同样地,在已经安装了其他Office应用程序的64位版本的同一台计算机上也不可以安装64位版本的Outlook 2010。
我已经测试过Otaku的答案,似乎即使未安装Outlook,Outlook的二进制位值也会被设置,尽管引用的文章没有明确指出这种情况。
Translated:我已经测试了Otaku的回答,发现即使没有安装Outlook, Outlook的位数值也会被设定,尽管所引用的文章没有清楚地表明这种情况。
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 }
{ https://dev59.com/-3NA5IYBdhLWcg3wjOre }
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;
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
}
我发现了一种检查Office位数的方法。
我们可以使用以下注册表键来检查Office 365和2016的位数:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration
32位平台 x86。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration
平台 x64 适用于 64 位。
请检查...
使用完全相同的DLL代码和完全相同的Outlook二进制路径(“c:/Program Files (x86)/…”)在同一台计算机上。
这意味着您可能需要使用“IMAGE_NT_HEADERS.FileHeader.Machine”条目自行测试二进制文件。
天啊,我讨厌一些Windows API的错误返回值(也请参见GetVersion()的谎言)。
GetBinaryType()
和注册表虚拟化?我不会期望它改变任何东西,特别是如果路径被准确给出的话。无论如何,在系统中没有其他位数的EXE文件,所以这一定是某种魔法(这些Windows的肮脏技巧的好词),但不是注册表魔法。 - chksr这段InnoSetup代码在我使用Win 10x64和Office 2016 x86下工作良好(使用'HKLM\SOFTWARE\Microsoft\Office\ClickToRun\Configuration'和键'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;
编辑:无需触碰RegistryKeys的解决方案-对不起Op。
我发现有一个C#的解决方案-原始代码可以在这里找到: https://blogs.msdn.microsoft.com/webdav_101/2016/07/26/sample-detecting-installed-outlook-and-its-bitness/
我根据我的需要进行了一些修改。
只需将正确的outlookPath传递给GetOutlookBitness()即可。
public enum BinaryType : uint
{
SCS_32BIT_BINARY = 0, // A 32-bit Windows-based application
SCS_64BIT_BINARY = 6, // A 64-bit Windows-based application.
SCS_DOS_BINARY = 1, // An MS-DOS – based application
SCS_OS216_BINARY = 5, // A 16-bit OS/2-based application
SCS_PIF_BINARY = 3, // A PIF file that executes an MS-DOS – based application
SCS_POSIX_BINARY = 4, // A POSIX – based application
SCS_WOW_BINARY = 2 // A 16-bit Windows-based application
}
[DllImport("kernel32.dll")]
static extern bool GetBinaryType(string lpApplicationName, out BinaryType lpBinaryType);
public int GetOutlookBitness(string FilePath)
{
int bitness = 0;
if (File.Exists(FilePath))
{
BinaryType type;
GetBinaryType(FilePath, out type);
switch (type)
{
case BinaryType.SCS_32BIT_BINARY:
bitness = 32;
break;
case BinaryType.SCS_64BIT_BINARY:
bitness = 64;
break;
}
}
return bitness;
}
以下是我在VBScript中使用的代码,用于检测64位Office的Outlook:
Dim WshShell, blnOffice64, strOutlookPath
Set WshShell = WScript.CreateObject("WScript.Shell")
blnOffice64=False
strOutlookPath=WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\outlook.exe\Path")
If WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") = "AMD64" And _
not instr(strOutlookPath, "x86") > 0 then
blnOffice64=True
wscript.echo "Office 64"
End If
C:\Program Files\Microsoft Office\Root\Office16\
。 - Paul
HKEY_LOCAL_MACHINE\Software\Microsoft\Office\16.0\Outlook\Bitness
键不存在。但是,HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\16.0\Outlook\Bitness
存在。 - lesscode