1

私は魔法のように動作する 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;
4

2 に答える 2

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")
于 2012-07-30T00:00:31.033 に答える
1

これを行う最善の方法は、ISPP を使用してファイルを列挙し、実行時に読み取ることができるコンパイル時に関連するエントリのリストを作成することです。

これは、パスカル配列に直接出力することも、実行時に抽出して読み取るファイルに出力することもできます。

于 2012-03-05T12:17:50.120 に答える