2014-09-04 17 views
6

Tôi cần tạo trình cài đặt Inno Setup đơn giản để sao chép ba bộ tệp khác nhau vào ba thư mục có thể chọn cho C: hoặc D: v.v.Thiết lập Inno với ba thư mục đích

Đây chỉ là tệp không có ứng dụng.

Tôi đã tìm thấy một tập lệnh "Nhắc thư mục bổ sung cho dữ liệu" nhưng chỉ có một thư mục trên trang tiếp theo.

Cảm ơn.

ví dụ:

enter image description here

http://badjohnny.com.au/temp/myinno.jpg

Edit: Đây là mã tôi nhận:

[Setup] 
AppName=MyProg 
AppVerName=MyProg 
DefaultDirName={pf}\MyProg 
DisableProgramGroupPage=yes 
UninstallDisplayIcon={app}\MyProg.exe 

[Files] 
;Main program that will be installed in {app} folder 
Source: MyProg.exe; DestDir: {app} 

;Database file that will installed where user choosed 
Source: DataBase.mdb; DestDir: {code:GetDataDir} 
[Code] 
var 
    DataDirPage: TInputDirWizardPage; 

procedure InitializeWizard; 
begin 
    { Create the page } 

    DataDirPage := CreateInputDirPage(wpSelectDir, 
    'Select Personal Data Directory', 'Where should personal data files be installed?', 
    'Select the folder in which Setup should install personal data files, ' + 
     'then click Next.', 
    False, ''); 
    DataDirPage.Add(''); 

    DataDirPage.Values[0] := GetPreviousData('DataDir', ''); 
end; 

procedure RegisterPreviousData(PreviousDataKey: Integer); 
begin 
    { Store the selected folder for further reinstall/upgrade } 
    SetPreviousData(PreviousDataKey, 'DataDir', DataDirPage.Values[0]); 
end; 

function NextButtonClick(CurPageID: Integer): Boolean; 
begin 
    { Set default folder if empty } 
    if DataDirPage.Values[0] = '' then 
    DataDirPage.Values[0] := ExpandConstant('{sd}\DataDir'); 
    Result := True; 
end; 

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, 
    MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String; 
var 
    S: String; 
begin 
    { Fill the 'Ready Memo' with the normal settings and the custom settings } 
    S := ''; 

    S := S + MemoDirInfo + NewLine + NewLine; 

    S := S + 'Database path' + NewLine; 
    S := S + Space + DataDirPage.Values[0] + NewLine; 

    Result := S; 
end; 

function GetDataDir(Param: String): String; 
begin 
    { Return the selected DataDir } 
    Result := DataDirPage.Values[0]; 
end; 
+1

Ví dụ bạn đã tìm thấy là những gì bạn cần làm nhưng bạn sẽ cần phải tạo ra ba điều khiển và có ba hàm để lấy đường dẫn. – Deanna

+1

Tôi đã đăng mã tôi có ở trên.Thanks – LuaStart

+1

Câu trả lời của tôi vẫn đứng, bạn chỉ cần gấp ba mục được thêm vào trang và mỗi lần được nhắc đến. – Deanna

Trả lời

9

Bạn có thể viết một cái gì đó như thế này:

[Setup] 
AppName=My Program 
AppVersion=1.5 
DefaultDirName={pf}\My Program 

[Files] 
; the parameter passed to the GetDir function here is the index of a directory 
; input page item, so the following 3 files will be installed each into one of 
; the directories specified in the input page items 
Source: "File1.txt"; DestDir: "{code:GetDir|0}" 
Source: "File2.txt"; DestDir: "{code:GetDir|1}" 
Source: "File3.txt"; DestDir: "{code:GetDir|2}" 
[Code] 
var 
    DirPage: TInputDirWizardPage; 

function GetDir(Param: String): String; 
begin 
    Result := DirPage.Values[StrToInt(Param)]; 
end; 

procedure InitializeWizard; 
begin 
    { create a directory input page } 
    DirPage := CreateInputDirPage(
    wpSelectDir, 'Caption', 'Description', 'SubCaption', False, ''); 
    { add directory input page items } 
    DirPage.Add('Prompt 1'); 
    DirPage.Add('Prompt 2'); 
    DirPage.Add('Prompt 3'); 
    { assign default directories for the items from the previously stored data; if } 
    { there are no data stored from the previous installation, use default folders } 
    { of your choice } 
    DirPage.Values[0] := GetPreviousData('Directory1', 'C:\HardcodedPath'); 
    DirPage.Values[1] := GetPreviousData('Directory2', ExpandConstant('{userdocs}')); 
    DirPage.Values[2] := GetPreviousData('Directory3', ExpandConstant('{localappdata}')); 
end; 

procedure RegisterPreviousData(PreviousDataKey: Integer); 
begin 
    { store chosen directories for the next run of the setup } 
    SetPreviousData(PreviousDataKey, 'Directory1', DirPage.Values[0]); 
    SetPreviousData(PreviousDataKey, 'Directory2', DirPage.Values[1]); 
    SetPreviousData(PreviousDataKey, 'Directory3', DirPage.Values[2]); 
end; 

Để đối phó với những tiêu chuẩn "thư mục cài đặt", xem:
Use two/multiple selected directories from custom page in Files section

Các vấn đề liên quan