如何在 Inno Setup 中找到用户选择的安装路径?

How do you find the user-selected install path in Inno Setup?

我需要获取用户选择安装我的应用程序的路径。

如果我设置 CreateAppDir=yes 并设置 DefaultDirName=C:\MyApp\,用户可以将其更改为其他目录。在他们这样做之后,我需要知道他们在下一个安装向导步骤中选择了哪个目录。我怎样才能得到这个值?

使用{app}常量。参考文献将其描述为:

The application directory, which the user selects on the Select Destination Location page of the wizard. For example: If you used {app}\MYPROG.EXE on an entry and the user selected "C:\MYPROG" as the application directory, Setup will translate it to "C:\MYPROG\MYPROG.EXE".

您可以选择使用 WizardDirValue 函数。这个被描述为:

Returns the current contents of the edit control on the Select Destination Location page of the wizard.

Unlike ExpandConstant('{app}'), this function will not fail if called after the wizard is shown but prior to the user selecting a directory. Rather, it will return the default directory name.