gpt4 book ai didi

installation - Inno Setup 的自定义页面向导

转载 作者:行者123 更新时间:2023-12-02 00:04:41 25 4
gpt4 key购买 nike

我一直致力于 Inno Setup 上的自定义页面。我有下面的示例代码示例,但是当我在我的 Inno 设置脚本编辑器上运行时,会弹出一个编译器错误。它说:“编译器错误:第 63 行:第 3 列:未知标识符“authentication_form_CreatePage”。我看不出有什么错误。但是有一个。如果有人能看到它并知道它,你能帮我解决这个问题吗?

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "NewSampleSetup"
#define MyAppVersion "1.0"
#define MyAppPublisher "Example"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "BarChartExample2.exe"

[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={{8226770F-1270-434F-B53E-5539E78AD05B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir=C:\Users\Intern1\Documents\Inno Setup Examples Output
OutputBaseFilename=Setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Users\stajyer1\Documents\Visual Studio 2012\Projects\BarChartExample2\BarChartExample2\bin\Debug\BarChartExample2.exe"; DestDir: " {app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files



[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram, {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[CustomMessages]
authentication_form_Caption=SQL Server Database Setup
authentication_form_Description=Choose SQL Server database you will be using (ask your administrator about its parameters)
authentication_form_Label1_Caption0=Server Name:
authentication_form_Label2_Caption0=Enter Path to SQL Server (e.g. .\SQLEXPRESS; DEVSERVER)
authentication_form_Label3_Caption0=User name:
authentication_form_Label4_Caption0=Password:
authentication_form_ServerNameEdit_Text0=-
authentication_form_WindowsRadioButton_Caption0=Use Windows Authentication
authentication_form_SqlRadioButton_Caption0=Use SQL Authentication
authentication_form_UserEdit_Text0=-
authentication_form_PasswordEdit_Text0=-

[Code]
procedure InitializeWizard();
begin
authentication_form_CreatePage(wpLicense);
end;

var
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
ServerNameEdit: TEdit;
WindowsRadioButton: TRadioButton;
SqlRadioButton: TRadioButton;
UserEdit: TEdit;
PasswordEdit: TEdit;

function authentication_form_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(
PreviousPageId,
ExpandConstant('{cm:authentication_form_Caption}'),
ExpandConstant('{cm:authentication_form_Description}')
);
Label1 := TLabel.Create(Page);
with Label1 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:authentication_form_Label1_Caption0}');
Left := ScaleX(16);
Top := ScaleY(0);
Width := ScaleX(84);
Height := ScaleY(17);
end;

Label2 := TLabel.Create(Page);
with Label2 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm: authentication_form_Label2_Caption0}');
Left := ScaleX(16);
Top := ScaleY(56);
Width := ScaleX(300);
Height := ScaleY(17);
end;

Label3 := TLabel.Create(Page);
with Label3 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm: authentication_form_Label3_Caption0}');
Left := ScaleX(56);
Top := ScaleY(136);
Width := ScaleX(70);
Height := ScaleY(17);
end;

Label4 := TLabel.Create(Page);
with Label4 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm: authentication_form_Label4_Caption0}');
Left := ScaleX(56);
Top := ScaleY(168);
Width := ScaleX(63);
Height := ScaleY(17);
end;

ServerNameEdit := TEdit.Create(Page);
with ServerNameEdit do
begin
Parent := Page.Surface;
Left := ScaleX(16);
Top := ScaleY(24);
Width := ScaleX(257);
Height := ScaleY(25);
TabOrder := 0;
Text := ExpandConstant('{cm: authentication_form_ServerNameEdit_Text0}');
end;

WindowsRadioButton := TRadioButton.Create(Page);
with WindowsRadioButton do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm: authentication_form_WindowsRadioButton_Caption0}');
Left := ScaleX(16);
Top := ScaleY(88);
Width := ScaleX(225);
Height := ScaleY(17);
Checked := True;
TabOrder := 1;
TabStop := True;
end;

SqlRadioButton := TRadioButton.Create(Page);
with SqlRadioButton do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm: authentication_form_SqlRadioButton_Caption0}');
Left := ScaleX(16);
Top := ScaleY(112);
Width := ScaleX(193);
Height := ScaleY(17);
TabOrder := 2;
end;

UserEdit := TEdit.Create(Page);
with UserEdit do
begin
Parent := Page.Surface;
Left := ScaleX(136);
Top := ScaleY(136);
Width := ScaleX(121);
Height := ScaleY(25);
TabOrder := 3;
Text := ExpandConstant('{cm: authentication_form_UserEdit_Text0}');
end;

PasswordEdit := TEdit.Create(Page);
with PasswordEdit do
begin
Parent := Page.Surface;
Left := ScaleX(136);
Top := ScaleY(168);
Width := ScaleX(121);
Height := ScaleY(25);
TabOrder := 4;
PasswordChar := '*';
Text := ExpandConstant('{cm: authentication_form_PasswordEdit_Text0}');
end;

with Page do
begin
OnNextButtonClick := @authentication_form_NextButtonClick;
end;

Result := Page.ID;
end;

function authentication_form_NextButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
if ServerNameEdit.Text <> '' then
begin
if SqlRadioButton.Checked then
begin
if UserEdit.Text = '' then
begin
MsgBox('You should enter user name', mbError, MB_OK);
Result := False;
end
else
begin
if PasswordEdit.Text = '' then
begin
MsgBox('You should enter password', mbError, MB_OK);
Result := False;
end
end
end
end
else
begin
MsgBox('You should enter path to SQL Server Database', mbError, MB_OK);
Result := False;
end;
end;

最佳答案

试试这个:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "NewSampleSetup"
#define MyAppVersion "1.0"
#define MyAppPublisher "Example"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "BarChartExample2.exe"

[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={{8226770F-1270-434F-B53E-5539E78AD05B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir=C:\Users\sandaa\Desktop
OutputBaseFilename=Setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked

[Files]
;Source: "C:\Users\stajyer1\Documents\Visual Studio 2012\Projects\BarChartExample2\BarChartExample2\bin\Debug\BarChartExample2.exe"; DestDir: " {app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files



[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram, {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent


[Code]
var

FirstLabel: TLabel;
SecondLabel: TLabel;
ThirdLabel: TLabel;
FourthLabel: TLabel;
ServerNameTextBox: TEdit;
WindowsRadioButton: TRadioButton;
SQLRadioButton: TRadioButton;
txtUserName: TEdit;
txtPassword: TEdit;


function AuthenticateDataPage(Page: TWizardPage): Boolean;
begin
Result :=True;
if ServerNameTextBox.Text <> '' then
begin
if SQLRadioButton.Checked then
begin
if txtUserName.Text ='' then
begin
MsgBox('You should enter user name', mbError, MB_OK);
Result :=False;
end
else
begin
if txtPassword.Text ='' then
begin
MsgBox('You should enter password', mbError, MB_OK);
Result :=False;
end
end
end
end
else
begin
MsgBox('You should enter path to SQL Server Database', mbError, MB_OK);
Result :=False;
end;
end;


function CreateDataPage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page :=CreateCustomPage(PreviousPageId,'SQL Server Database Setup',
'Choose SQL Server database you will be using (ask your administrator about its parameters');

FirstLabel :=TLabel.Create(Page);
with FirstLabel do
begin
Parent :=Page.Surface;
Caption :='Server Name';
Left :=ScaleX(16);
Top :=ScaleY(0);
Width :=ScaleX(84);
Height :=ScaleY(17);
end;

SecondLabel :=TLabel.Create(Page);
With SecondLabel Do
begin
Parent :=Page.Surface;
Caption :='Enter Path to SQL Server (e.g. .\SQLEXPRESS; DEVSERVER)';
Left :=ScaleX(16);
Top :=ScaleY(56);
Width :=ScaleX(300);
Height :=ScaleY(17);
end;

ThirdLabel :=TLabel.Create(Page);
with ThirdLabel do
begin
Parent :=Page.Surface;
Caption :='User name';
Left :=ScaleX(56);
Top :=ScaleY(136);
Width :=ScaleX(70);
Height :=ScaleY(17);
end;

FourthLabel :=TLabel.Create(Page);
with FourthLabel do
begin
Parent :=Page.Surface;
Caption :='Password';
Left :=ScaleX(56);
Top :=ScaleY(168);
Width :=ScaleX(63);
Height :=ScaleY(17);
end;

ServerNameTextBox :=TEdit.Create(Page);
with ServerNameTextBox do
begin
Parent :=Page.Surface;
Left :=ScaleX(16);
Top :=ScaleY(24);
Width :=ScaleX(257);
Height :=ScaleY(25);
TabOrder :=0;
Text :='';
end;


WindowsRadioButton :=TRadioButton.Create(Page);
with WindowsRadioButton do
begin
Parent :=Page.Surface;
Caption :='Use Windows Authentication';
Left :=ScaleX(16);
Top :=ScaleY(88);
Width :=ScaleX(225);
Height :=ScaleY(17);
Checked :=True;
TabOrder :=1;
TabStop :=True;
end;

SQLRadioButton :=TRadioButton.Create(Page);
with SQLRadioButton do
begin
Parent :=Page.Surface;
Caption :='Use SQL Authentication';
Left :=ScaleX(16);
Top :=ScaleY(112);
Width :=ScaleX(193);
Height :=ScaleY(17);
TabOrder :=2;
end;


txtUserName :=TEdit.Create(Page);
with txtUserName do
begin
Parent :=Page.Surface;
Left :=ScaleX(136);
Top :=ScaleY(136);
Width :=ScaleX(121);
Height :=ScaleY(25);
TabOrder :=3;
Text :='';
end;

txtPassword :=TEdit.Create(Page);
with txtPassword do
begin
Parent :=Page.Surface;
Left :=ScaleX(136);
Top :=ScaleY(168);
Width :=ScaleX(121);
Height :=ScaleY(25);
TabOrder :=4;
PasswordChar :='*';
Text :='';
end;


with Page do
begin
OnNextButtonClick :=@AuthenticateDataPage;
end;

Result :=Page.ID;

end;

procedure InitializeWizard();
begin
CreateDataPage(wpLicense);
end;

我唯一遗漏的是自定义消息。

关于installation - Inno Setup 的自定义页面向导,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19181336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com