我有一个INNO安装程序,就像一个魅力。现在我需要为用户添加一个预安装的主题选项,以便为应用程序选择主题。这些主题在部署目录中定义,该目录在安装时将被复制到{tmp}文件夹。
我要做的是在此目录部分查找特定目录/文件以确定主题选项。当我找到主题时,我会在组合框中添加一个选项供用户选择。然后,此选择将影响应用程序的安装(也来自{tmp}区域)。
我的问题是,在单击安装按钮之前,文件不会解压缩到{tmp}目录。有没有办法窥视压缩文件结构或在安装之前将这些文件强制到{tmp}目录?每个主题的文件结构都不同,并且基于客户,只有某些主题可用。
之前我使用过ExtractTemporaryFile方法,但在提取目录之前,我不知道运行时存在哪些主题。能够提取整个目录树会很高兴,但我找不到一个简单的方法。
感谢您的帮助。
以下是我最初尝试做的示例脚本:
[Setup]
AppName=Test
AppVersion=1.5
DefaultDirName={pf}\test
OutputDir=Output
OutputBaseFilename=tt
DisableReadyPage=false
[Files]
;;Source: readme.txt; DestDir: {tmp}\App\deploy\themes\theme1; Flags: ignoreversion replacesameversion
;;Source: readme.txt; DestDir: {tmp}\App\deploy\themes\theme2; Flags: ignoreversion replacesameversion
;;Source: readme.txt; DestDir: {tmp}\App\deploy\themes\theme3; Flags: ignoreversion replacesameversion
;;Source: readme.txt; DestDir: {tmp}\App\deploy\themes\theme4; Flags: ignoreversion replacesameversion
Source: App\*.*; DestDir: {tmp}\App; Flags: ignoreversion replacesameversion recursesubdirs createallsubdirs
Source: readme.txt; DestDir: {app}; Flags: ignoreversion replacesameversion
[Run]
[Code]
var
curDir : String;
TestPage : TWizardPage;
ThemeComboBox: TNewComboBox;
procedure InitializeWizard;
begin
TestPage := CreateCustomPage(wpSelectTasks, 'My test page', 'run test');
// create the theme combo box
ThemeComboBox := TNewComboBox.Create(TestPage);
ThemeComboBox.Name := 'themeselection';
ThemeComboBox.Width := TestPage.SurfaceWidth;
ThemeComboBox.Parent := TestPage.Surface;
ThemeComboBox.Style := csDropDownList;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ThemeDir: String;
begin
Result := True;
if CurPageID = wpSelectDir then
begin
// look for the networks and then add the ones that exist to the combo box
ThemeDir := ExpandConstant('{tmp}\App\deploy\themes\tmeme1');
MsgBox(ThemeDir, mbInformation, MB_OK);
if DirExists(ThemeDir) then
begin
// populate the combo box
// this is theme1 so it is Standard
ThemeComboBox.Items.Add('Standard');
end;
ThemeDir := ExpandConstant('{tmp}\App\deploy\themes\theme2');
if DirExists(ThemeDir) then
begin
// populate the combo box
ThemeComboBox.Items.Add('theme2');
end;
ThemeDir := ExpandConstant('{tmp}\App\deploy\themes\theme3');
if DirExists(ThemeDir) then
begin
// populate the combo box
ThemeComboBox.Items.Add('theme3');
end;
ThemeDir := ExpandConstant('{tmp}\App\deploy\themes\theme4');
if DirExists(ThemeDir) then
begin
// populate the combo box
ThemeComboBox.Items.Add('theme4');
end;
end;
end;
答案 0 :(得分:1)
执行此操作的最佳方法是使用ISPP枚举文件,并在编译时构建相关条目列表,以便在运行时读取。
这可以直接输出到pascal数组,也可以输出到运行时提取和读取的文件。
答案 1 :(得分:1)
很晚,我知道:-)只是用代码示例来完成你的问题;以下示例使用SearchMask
变量指定的路径上的所有文件夹名称填充组合框。每次在指定位置找到文件夹时,它都会在字符串列表中添加一行。完成对位置的搜索后,将字符串列表分配给组合框:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: App\*.*; DestDir: {tmp}\App; Flags: ignoreversion
[Code]
var
CustomPage: TWizardPage;
procedure InitializeWizard;
var
ThemeList: TStringList;
ThemeComboBox: TNewComboBox;
begin
CustomPage := CreateCustomPage(wpWelcome, 'Theme selection page', '');
ThemeComboBox := TNewComboBox.Create(WizardForm);
ThemeComboBox.Parent := CustomPage.Surface;
ThemeComboBox.Style := csDropDownList;
ThemeComboBox.Width := CustomPage.SurfaceWidth;
ThemeList := TStringList.Create;
try
#define SearchHandle
#define SearchResult
#define SearchMask "App\Deploy\Themes\*.*"
#sub ProcessFoundFile
#define FileName FindGetFileName(SearchHandle)
#if (FileName != ".") && (FileName != "..")
#emit ' ThemeList.Add(''' + FileName + ''');'
#endif
#endsub
#for {SearchHandle = SearchResult = FindFirst(SearchMask, faDirectory); \
SearchResult; SearchResult = FindNext(SearchHandle)} ProcessFoundFile
#if SearchHandle
#expr FindClose(SearchHandle)
#endif
ThemeComboBox.Items.Assign(ThemeList);
finally
ThemeList.Free;
end;
end;
// you can save the current script file output after compilation preprocessing
// to see the result
#expr SaveToFile("d:\OutputScript.iss")