【发布时间】:2013-01-31 17:25:46
【问题描述】:
我需要用户浏览到一个文件,选择它,然后将该文件从选定的源复制到应用程序文件夹。
关注这篇文章 How to show/use the user selected app path {app} in InputDirPage in Inno Setup? 和 Inno Setup 文档,我来到了这段代码:
[Files]
Source: {code:GetDBPath}; DestDir: "{app}"; Flags: confirmoverwrite uninsneveruninstall;
[Code]
var
SelectDBPage: TInputDirWizardPage;
DBPath: String;
procedure InitializeWizard;
begin
SelectDBPage := CreateInputDirPage(wpSelectDir, 'Select file', 'Select file', 'Select file', False, '');
SelectDBPage.Add('');
SelectDBPage.Values[0] := ExpandConstant('{src}\DB.FDB');
DBPath := SelectDBPage.Values[0];
end;
function GetDBPath():String;
begin
Result := DBPath;
end;
我的问题是检索文件路径。在指令“源:{code:GetDBPath}”中,我收到“未知文件名前缀 {code:”错误。 如何在 [File] 部分引用选定的文件路径?
谢谢
【问题讨论】:
-
欢迎来到 StackOverflow。看起来你很困惑。 [files] 部分在编译时从脚本中读取。然后编译器生成安装程序,其中包含安装程序的所有文件和说明。 InitializeWizard 在运行时(运行生成的安装程序时)调用,因此您无法显示向导页面来更改设置中包含的文件。这与编程语言的编译时和运行时非常相似。
-
你的问题不清楚的是,如果你想让 user 在编译时选择一个文件来包含在你的脚本中,或者你想让用户在目标计算机中选择一个文件并在运行时将该文件移动/复制到该目标计算机上的其他位置。