如何强制Inno Setup动态设置安装文件夹

How to force Inno Setup to set the installation folder dynamically

我正在创建安装包,用户应该只能将其安装在特定位置。

为此,我阅读了 [Code] 部分中的一些注册表值以确定安装路径。

有了安装路径,我需要强制 Inno Setup 在 运行 时将安装文件夹设置到特定位置。

这在 Inno Setup 中可行吗?如果是这样,应该使用哪一段脚本?

谢谢。

[Setup]
DefaultDirName={code:GetDefaultDirName}
DisableDirPage=Yes

[Code]

function GetDefaultDirName(Param: string): string;
begin
  Result := ...;
end;