Inno Setup 运行 代码根据设置类型
Inno Setup Run code according to setup type
我想提供几种不同的安装类型,对我的安装程序执行不同的操作:如果选择了 "ApplicationServer" 类型,则只执行部分代码。如果改为选择客户端类型,则仅执行这部分过程。
我试图将 2 "blocks" 代码包含在一个名为
的函数中
[Types]
Name: "application"; Description: "{cm:ApplicationServer}"
Name: "client"; Description: "{cm:Client}"
[CustomMessages]
ApplicationServer=Application Server:
Client=Client:
if first choice selected,我要执行由几个程序,常量,变量组成的特定代码到运行一系列SQL脚本,而如果second是选择我需要在代码区域执行一些其他的东西,像这样:
[Code]
function ApplicationServer(blabla)
begin:
{ <!This part only to run for ApplicationServer type!> }
{ following constants and variables for the ADO Connection + SQL script run }
const
myconstant1=blabla;
var
myvar1=blabla;
{ here all the procedure to define and manage an ADO Connection to run a sql script }
{ procedure 1 }
{ procedure 2 }
end
function Client(blabla)
begin:
{ <!This part only to run for Client type!> }
{ following constants and variables only for performing some stuffs on top of client }
const
myconstant2=blabla;
var
myvar2=blabla;
{ procedure 3 }
{ procedure 4 }
end
有没有办法根据安装类型运行管理代码的特定部分运行?
谢谢。
使用WizardSetupType
support function.
您可能想要签到 CurStepChanged
event function。
procedure ApplicationServer;
begin
{ procedure 1 }
{ procedure 2 }
end;
procedure Client;
begin
{ procedure 1 }
{ procedure 2 }
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
SetupType: string;
begin
Log(Format('CurStepChanged %d', [CurStep]));
if CurStep = ssInstall then
begin
SetupType := WizardSetupType(False);
if SetupType = 'application' then
begin
Log('Installing application server');
ApplicationServer;
end
else
if SetupType = 'client' then
begin
Log('Installing client');
Client;
end
else
begin
Log('Unexpected setup type: ' + SetupType);
end;
end;
end;
Pascal 脚本不支持局部常量,只支持全局常量。
目前还不清楚,你想要什么,如果你想要一个局部常量或有条件地初始化一个全局常量。无论如何你不能做后者,常数是常数,它不能有不同的值。
与您的变量相同。 这些是局部变量还是你想有条件地给全局变量赋值?
我想提供几种不同的安装类型,对我的安装程序执行不同的操作:如果选择了 "ApplicationServer" 类型,则只执行部分代码。如果改为选择客户端类型,则仅执行这部分过程。
我试图将 2 "blocks" 代码包含在一个名为
的函数中[Types]
Name: "application"; Description: "{cm:ApplicationServer}"
Name: "client"; Description: "{cm:Client}"
[CustomMessages]
ApplicationServer=Application Server:
Client=Client:
if first choice selected,我要执行由几个程序,常量,变量组成的特定代码到运行一系列SQL脚本,而如果second是选择我需要在代码区域执行一些其他的东西,像这样:
[Code]
function ApplicationServer(blabla)
begin:
{ <!This part only to run for ApplicationServer type!> }
{ following constants and variables for the ADO Connection + SQL script run }
const
myconstant1=blabla;
var
myvar1=blabla;
{ here all the procedure to define and manage an ADO Connection to run a sql script }
{ procedure 1 }
{ procedure 2 }
end
function Client(blabla)
begin:
{ <!This part only to run for Client type!> }
{ following constants and variables only for performing some stuffs on top of client }
const
myconstant2=blabla;
var
myvar2=blabla;
{ procedure 3 }
{ procedure 4 }
end
有没有办法根据安装类型运行管理代码的特定部分运行?
谢谢。
使用WizardSetupType
support function.
您可能想要签到 CurStepChanged
event function。
procedure ApplicationServer;
begin
{ procedure 1 }
{ procedure 2 }
end;
procedure Client;
begin
{ procedure 1 }
{ procedure 2 }
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
SetupType: string;
begin
Log(Format('CurStepChanged %d', [CurStep]));
if CurStep = ssInstall then
begin
SetupType := WizardSetupType(False);
if SetupType = 'application' then
begin
Log('Installing application server');
ApplicationServer;
end
else
if SetupType = 'client' then
begin
Log('Installing client');
Client;
end
else
begin
Log('Unexpected setup type: ' + SetupType);
end;
end;
end;
Pascal 脚本不支持局部常量,只支持全局常量。
目前还不清楚,你想要什么,如果你想要一个局部常量或有条件地初始化一个全局常量。无论如何你不能做后者,常数是常数,它不能有不同的值。
与您的变量相同。 这些是局部变量还是你想有条件地给全局变量赋值?