Inno Setup DefaultDirName问题

时间:2014-10-01 11:22:52

标签: directory installer inno-setup pascal

我对Inno Setup DefaultDirName有疑问。我的代码如下所示:

#define MyAppName "My Program"
#define MyAppVersion "1.0"
#define MyAppPublisher "My site"
#define MyAppURL "mysite.net"
#define MyAppExeName "My Program.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{36D5C912-2F45-4295-956F-53E668BD6094}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=c:\Please Choose the Path to Your Program
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=D:\My Program\EULA.txt
OutputDir=D:\My Program\Inno\
OutputBaseFilename=setup
SetupIconFile=D:\My Program\\Graphics\Icon.ico
Compression=lzma
SolidCompression=yes

除了一件事之外,一切都像我想要的那样。我的程序用于修改几个不同的软件。这就是我无法为所有这些目录指定一个默认目录的原因。同时我想清楚地指出用户想要选择的目录。这就是为什么我这样写的:

DefaultDirName=c:\Please Choose the Path to Your Program

该行代码的问题在于,当用户指向某个目录时,我的安装程序正在尝试向该目录添加“\请选择您的程序路径”(这显然会导致我的程序无法正常工作)。如何防止这种情况发生,但仍然让用户知道他在安装我的程序时应该选择哪个目录?

1 个答案:

答案 0 :(得分:3)

AppendDefaultDirName指令设置为no,例如:

[Setup]
...
AppendDefaultDirName=no

正如参考文献所说(我强调):

  

默认情况下,当浏览器显示对话框中的文件夹时...   单击“选择目标位置”向导页面上的按钮,   安装程序会自动将DefaultDirName的最后一个组件附加到   新路径

     

例如,如果DefaultDirName为{pf} \ My Program并且单击“Z:\”,则新路径将变为“Z:\ My Program”。

     

将此指令设置为no会禁用上述行为。在   此外,它会使“新建文件夹”按钮出现在对话框中。