2012-03-02 1 views
1

나는 매력처럼 작동하는 INNO 설치 프로그램을 가지고 있습니다. 이제 사용자가 응용 프로그램의 테마를 선택하기 위해 사전 설치되는 테마 옵션을 추가해야합니다. 이러한 테마는 설치시 {tmp} 폴더에 복사 된 배치 디렉토리에 정의됩니다.설치 전에 설치 프로그램이 시작될 때 INNO 설치 디렉토리 트리 추출

내가하려는 것은 특정 디렉토리/파일에 대한이 디렉토리 섹션에서 테마 옵션을 결정하는 것입니다. 테마를 찾으면 사용자가 선택할 수있는 옵션을 콤보 상자에 추가합니다. 이 선택은 응용 프로그램 설치에 영향을줍니다 ({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; 

답변

1

가장 좋은 방법은 파일을 열거하고 컴파일시 관련 항목의 목록을 구축 ISPP를 사용한다 : 다음

내가 원래 뭘하려고 있었는지의 예 스크립트입니다 런타임에 읽을 수 있습니다.

이것은 파스칼 배열로 직접 출력하거나 런타임에 추출하여 읽는 파일로 출력 할 수 있습니다.

+1

예를 들려 줄 수 있습니까? 나는 네가하는 말을 잘 모르겠다. 감사. –

+0

스티브, 예제 추가 (아주 늦었 어 :-) @Deanna, InnoSetup 전 처리기에서 런타임 출력 (* 출력을 파스칼 배열로 바로 출력)으로 출력하는 것이 가능하다고 생각하지 않습니다. 상수 배열은 지원되지 않습니다. – TLama

+1

@TLama 당신이 시연했듯이 배열을 채울 코드를 출력 할 수 있습니다 :) – Deanna

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")