Сделал скрипт, который предлагает пользователю выбрать тип установки: Простая установка ( Просто устанавливаются файлы) и Простая установка + Создание базы данных. Что нужно прописать в ShouldSkipPage чтобы при выборе простой установке переходило сразу на установку, а при выборе второго варианта отображались страницы, которые я создал
Код:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Barnet POS"
#define MyAppVersion "1.6"
#define MyAppPublisher "Barnet POS, inc"
#define MyAppURL "http://barnetbc.ru"
#define MyAppExeName "BarnetManager.exe"
#define SQLSERVERNAME "localhost\SQLEXPRESS"
#define SQLDATABASENAME "barnet"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{84A2C789-E6B0-4F26-832A-07D3A8AD0316}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:\BarnetPOSScript\SourceProgram\BarnetManager.exe"; DestDir: "{app}"; Flags: ignoreversion;
Source: "C:\BarnetPOSScript\SourceProgram\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
function CheckAlias(): Boolean;
var
ADOConnection: Variant;
begin
Result := false;
try
ADOConnection := CreateOleObject('ADODB.Connection');
ADOConnection.ConnectionString := 'Provider=SQLOLEDB;Data Source={#SQLSERVERNAME};Initial Catalog={#SQLDATABASENAME};User Id=sa;Password=123456;'
ADOConnection.Open;
try
Result := true;
finally
ADOConnection.Close;
end;
except
Result := false;
end;
end;
procedure ButtonOnClick(Sender: TObject);
begin
CheckAlias();
MsgBox('Соединение установлено', mbInformation, mb_Ok);
end;
procedure ButtonOnClick2(Sender: TObject);
begin
MsgBox('You clicked the button!!!!!', mbInformation, mb_Ok);
end;
procedure FormButtonOnClick(Sender: TObject);
var
OKButton: TNewButton;
OKButton2: TNewButton;
Form: TSetupForm;
begin
Form := CreateCustomForm();
try
OKButton := TNewButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := 'OK';
OKButton.ModalResult := mrOk;
OKButton.Default := True;
OKButton2 := TNewButton.Create(Form);
OKButton2.Parent := Form;
OKButton2.Width := ScaleX(75);
OKButton2.Height := ScaleY(23);
OKButton2.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
OKButton2.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton2.Caption := 'OK';
OKButton2.ModalResult := mrOk;
OKButton2.Default := True;
finally
Form.Free();
end;
end;
//Страницы инсталлятора!
procedure CreateTheWizardPages;
var
Page, Page1, Page2: TWizardPage;
Button, Button2, FormButton: TNewButton;
Edit2, strServerName, strDabaseName : TNewEdit;
PasswordEdit: TPasswordEdit;
StaticText, StaticText1, StaticText2, StaticText3, StaticText4: TNewStaticText;
CheckListBox2: TNewCheckListBox;
InputPage: TInputFileWizardPage;
begin
// 1-я страница (Выбор Установки)!
Page := CreateCustomPage(wpWelcome, 'Тип Установки', 'TNewCheckListBox');
CheckListBox2 := TNewCheckListBox.Create(Page);
CheckListBox2.Top := ScaleY(8);
CheckListBox2.Width := Page.SurfaceWidth;
CheckListBox2.Height := ScaleY(97);
CheckListBox2.BorderStyle := bsNone;
CheckListBox2.ParentColor := True;
CheckListBox2.MinItemHeight := WizardForm.TasksList.MinItemHeight;
CheckListBox2.ShowLines := False;
CheckListBox2.WantTabs := True;
CheckListBox2.Parent := Page.Surface;
CheckListBox2.AddGroup('Выберите тип установки', '', 0, nil);
CheckListBox2.AddRadioButton('Установить файлы', '', 0, True, True, nil);
CheckListBox2.AddRadioButton('Установить файлы + создать новую базу данных', '', 0, False, True, nil);
// 2-я страница (Создание БАЗЫ ДАННЫХ)!
Page1 := CreateCustomPage(Page.ID, 'Создание новой базы данных', 'Сервер и Наименование');
StaticText := TNewStaticText.Create(Page1);
StaticText.Parent := Page1.Surface;
StaticText.Caption := 'Наименование сервера';
StaticText.AutoSize := True;
strServerName := TNewEdit.Create(Page1);
strServerName.Top := StaticText.Top + StaticText.Height + ScaleY(2);
strServerName.Width := Page1.SurfaceWidth div 2 - ScaleX(8);
strServerName.Text := '{#SQLSERVERNAME}';
strServerName.Parent := Page1.Surface;
StaticText1 := TNewStaticText.Create(Page1);
StaticText1.Parent := Page1.Surface;
StaticText1.Top := strServerName.Top + strServerName.Height + ScaleY(8);
StaticText1.Caption := 'Укажите имя базы данных';
StaticText1.AutoSize := True;
strDabaseName := TNewEdit.Create(Page1);
strDabaseName.Top := StaticText1.Top + StaticText1.Height + ScaleY(8);
strDabaseName.Width := Page1.SurfaceWidth div 2 - ScaleX(8);
strDabaseName.Text := '{#SQLDATABASENAME}';
strDabaseName.Parent := Page1.Surface;
Button := TNewButton.Create(Page1);
Button.Width := ScaleX(150);
Button.Height := ScaleY(23);
Button.Top := strDabaseName.Top + strDabaseName.Height + ScaleY(8);
Button.Caption := 'Проверить соединение';
Button.OnClick := @ButtonOnClick;
Button.Parent := Page1.Surface;
//3-я страница (Загрузка бэкапа)!
InputPage := CreateInputFilePage(Page1.ID, 'Создание новой базы данных', 'Загрузка шаблона базы данных',
'Выберите файл');
InputPage.Add('Расширение файла .bak', 'BAK files (*.bak)|*.bak', '.bak');
Button2 := TNewButton.Create(InputPage);
Button2.Width := ScaleX(90);
Button2.Height := ScaleY(23);
Button2.Left := ScaleX(10);
Button2.Top := ScaleY(80);
Button2.Caption := 'Загрузить';
Button2.OnClick := @ButtonOnClick2;
Button2.Parent := InputPage.Surface;
//InputPage.Values[0] := GetPreviousData('Расширение файла .bak', ExpandConstant('{sysuserinfoname}'));
end;
procedure InitializeWizard();
begin
{ Custom wizard pages }
CreateTheWizardPages;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
function NextButtonClick(CurPageID: Integer): Boolean;
var
Последнее редактирование: