You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Inno Setup能否检测支持x64模拟的ARM64架构Windows 11?

Inno Setup在ARM64 Windows上检测x64兼容性的解决方案

现状说明

目前Inno Setup官方尚未推出文档提及的x64compatible标识或IsX64Compatible内置函数,无法直接通过内置方案区分支持x64模拟的ARM64系统和不支持的旧ARM设备。之前用ArchitecturesAllowed=x64会直接拦截所有ARM64设备,直接添加arm64又会放行不具备x64模拟能力的旧ARM系统,因此需要通过系统调用实现自定义检测。

自定义检测方案

1. 通过Windows API实现准确检测

可以调用GetSystemWow64Directory2和GetWindowsArchitecture两个API来完成检测,逻辑是:非ARM64系统直接判断是否为x64架构;ARM64系统则通过检测是否存在x64的Wow64目录来确认是否支持x64模拟。

首先在脚本中声明所需的API和常量:

const
  PROCESSOR_ARCHITECTURE_AMD64 = 9;

function GetWindowsArchitecture: Word;
  external 'GetWindowsArchitecture@files:isxdl.dll stdcall';

function GetSystemWow64Directory2(lpBuffer: String; uSize: DWORD; usProcessorArchitecture: Word): DWORD;
  external 'GetSystemWow64Directory2W@kernel32.dll stdcall';

然后编写检测函数:

function IsX64Compatible: Boolean;
var
  SysWow64Dir: String;
begin
  // 非ARM64系统直接判断是否为x64架构
  if GetWindowsArchitecture <> waARM64 then
  begin
    Result := (GetWindowsArchitecture = waX64);
    Exit;
  end;

  // ARM64系统检测是否支持x64模拟:尝试获取x64的Wow64目录
  SetLength(SysWow64Dir, MAX_PATH);
  Result := (GetSystemWow64Directory2(SysWow64Dir, MAX_PATH, PROCESSOR_ARCHITECTURE_AMD64) > 0);
end;

2. 在安装流程中应用检测逻辑

方式一:初始化阶段拦截不符合条件的设备

在InitializeSetup函数中调用检测逻辑,不满足条件则终止安装并提示:

function InitializeSetup: Boolean;
begin
  Result := True;
  if not IsX64Compatible then
  begin
    MsgBox('本程序仅支持x64架构系统或具备x64模拟能力的ARM64 Windows系统。', mbCriticalError, MB_OK);
    Result := False;
  end;
end;

方式二:配合架构配置实现精准过滤

先放宽ArchitecturesAllowed的范围,再通过检测函数筛选符合条件的ARM64系统:

[Setup]
ArchitecturesAllowed=x64 arm64
ArchitecturesInstallIn64BitMode=x64

如果需要针对特定组件或文件做限制,可以在对应项的Check参数中指定IsX64Compatible:

[Components]
Name=MainProgram; Description=主程序; Types=full compact; Check=IsX64Compatible

补充说明

  • GetSystemWow64Directory2是Windows 10 1903及以上版本支持的API,刚好覆盖支持x64模拟的ARM64 Windows系统(Windows 11及部分Windows 10后期版本)。
  • 这种API检测方式比注册表检查更可靠,因为注册表项可能被修改,而API调用直接反映系统的实际能力。

内容的提问来源于stack exchange,提问作者StayOnTarget

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 03:30:47