Windows 11支持仿真x64硬件,同时实际运行在ARM64平台上。这方面的一个例子是在Mac上的虚拟机中运行Windows。
以前,我的Inno安装程序只是使用以下方法来确保PC能够运行我们的软件:
ArchitecturesAllowed=x64
但是,在基于ARM的系统上,例如给出的示例,这会导致设置终止,因为它(正确地)将arm64
视为体系结构。
我不能仅仅将arm64
添加到这一行中,因为这不会区分那些没有x64仿真功能的基于ARM的老系统和那些这样做的系统。
希望在Inno安装谷歌集团中讨论这个主题如下:
约旦罗素2021年10月4日下午5:45:40 ..。 如果他们要切换到"ArchitecturesInstall64BitMode=x64 arm64",那么您应该得到x64文件。然而,不幸的是,x64文件也会安装在不支持x64仿真的旧ARM64构建上,从而导致一个非功能应用程序。 ..。 不过,我仍然计划在不久的将来增加对检测x64仿真的官方支持。一个新的体系结构标识符"x64compatible“将匹配x64 Windows和ARM64 Windows并支持x64仿真,还将添加一个IsX64Compatible函数。为了鼓励采用"x64compatible“,以便可以在ARM64上安装更多的x64应用程序,现有的"x64”将被废弃并重命名为"x64strict",而编译器稍后将在使用"x64“时打印警告。
然而,相关的Inno文档部分似乎没有提到这一点。(允许建筑,isarm64)
有什么内置的方法来做吗?
如果没有,我可能不得不尝试一些直接的系统调用,如如何检测Windows是否支持运行x64进程?中提到的那些。
发布于 2022-09-13 18:54:39
如您所链接的问题所示,您可以在Windows11上调用WinAPI函数来确定x64支持。在较早版本的Windows上,使用Inno安装支持功能
像这样的东西应该可以做(但是我没有ARM64机器来测试这个)。
[Code]
const
IMAGE_FILE_MACHINE_AMD64 = $8664;
function GetMachineTypeAttributes(
Machine: Word; var MachineTypeAttributes: Integer): HRESULT;
external 'GetMachineTypeAttributes@Kernel32.dll stdcall delayload';
<event('InitializeSetup')>
function InitializeSetupCheckArchitecture(): Boolean;
var
MachineTypeAttributes: Integer;
Arch: TSetupProcessorArchitecture;
begin
if IsWindows11OrNewer then
begin
OleCheck(
GetMachineTypeAttributes(IMAGE_FILE_MACHINE_AMD64, MachineTypeAttributes));
if MachineTypeAttributes <> 0 then
begin
Log('Windows 11 or newer, with x64 support');
Result := True;
end
else
begin
Log('Windows 11 or newer, without x64 support');
Result := False;
end;
end
else
begin
Arch := ProcessorArchitecture;
if Arch = paX64 then
begin
Log('Windows 10 or older, on x64 architecture');
Result := True;
end
else
begin
Log('Windows 10 or older, not on x64 architecture');
Result := False;
end;
end;
if not Result then
begin
MsgBox('This product can be installed on system with x64 support only.',
mbError, MB_OK);
end;
end;
该代码完全替换了ArchitecturesAllowed
指令(假设它没有设置,尽管将其设置为x64 arm64
不会有什么害处)。
IsWindows11OrNewer
来自在Inno安装程序中确定Windows版本。
https://stackoverflow.com/questions/73707415
复制相似问题