我想用inno安装程序上加个选项, 要怎么写?(100分)

  • 主题发起人 主题发起人 winni
  • 开始时间 开始时间
W

winni

Unregistered / Unconfirmed
GUEST, unregistred user!
单选框: 电信 网通
 
大富翁真的没落了,没次提问都没人回答, 最后花时间自己搞定了
 
还好你自己搞定了,要不然真是没落了 [:D]
 
楼主虽然自己搞定了,不过,我这既然有现成的,就发个上来给找到这个帖子的朋友参考一下吧:
组件设置,可放在setup段后面
[Types]
;设置若干个安装主题,供用户根据不同目的选择安装
Name: "JitLocal"; Description: "单机版"
Name: "JitClnt"; Description: "网络版客户端"
Name: "JitServ"; Description: "网络版服务器"
Name: "Custom"; Description: "自定义安装"; Flags: iscustom
[Components]
;本节列出待安装的所有组件。如果[Type]节中的一个安装主题需要某个组件,就在此组件对应的Types:保留字后面列出此主题名
Name: IB7clt; Description: 客户端数据库驱动; Types: JitClnt JitLocal Custom
Name: jclnt; Description: 饰品客户端主程序; Types: JitClnt JitLocal Custom
Name: jclntord; Description: 订单客户端主程序; Types: JitClnt JitLocal Custom
Name: IB7svr; Description: 服务器数据库系统; Types: JitServ JitLocal
Name: Base; Description: 原始数据库; Types: JitServ JitLocal
Name: Jhelp; Description: 使用教程; Types: JitClnt JitServ JitLocal Custom
Name: Jreg; Description: 授权程序; Types: JitClnt JitServ JitLocal
Name: Jlocal; Description: 单机识别; Types: JitLocal

然后在每个文件或者任务后面加上组件属性:
Source: "E:/资料/help/index.htm"; DestDir: "{app}/help"; Flags: ignoreversion; Components: jclnt Jhelp



在inno setup脚本的最后加入如下代码即可:
代码:
var

  UsagePage: TInputOptionWizardPage;

procedure InitializeWizard;
begin
  { Create the pages }

  UsagePage := CreateInputOptionPage(wplicense,
    '程序组件', '您希望的安装模式',
    '请选择您希望的安装模式:',
    True, False);
  UsagePage.Add('单机版 (在单台电脑上同时安装客户端和服务器端)');
  UsagePage.Add('网络版客户端 (公司多台电脑联网使用)');
  UsagePage.Add('网络版服务器端 (公司内的主数据库服务器安装)');
  UsagePage.Add('自定义 (自己选择要安装的组件,供熟悉的用户采用)');
{ Set default values, using settings that were stored last time if possible }

  case GetPreviousData('UsageMode', '') of
    '单机版': UsagePage.SelectedValueIndex := 0;
    '网络版客户端': UsagePage.SelectedValueIndex := 1;
    '网络版服务器端': UsagePage.SelectedValueIndex := 2;
    '自定义': UsagePage.SelectedValueIndex := 3;
  else
    UsagePage.SelectedValueIndex := 0;
  end;

end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
var
  UsageMode: String;
begin
  { Store the settings so we can restore them next time }
  case UsagePage.SelectedValueIndex of
    0: UsageMode := '单机版';
    1: UsageMode := '网络版客户端';
    2: UsageMode := '网络版服务器端';
    3: UsageMode := '自定义';
  end;
  SetPreviousData(PreviousDataKey, 'UsageMode', UsageMode);
end;

function ShouldSkipPage(PageID: Integer): Boolean;

begin
  { 数据库服务器机器名输入页面,只在选服务器端后出现 }
  if (PageID = wpSelectComponents) then
   begin
     WizardForm.TypesCombo.itemindex:= UsagePage.SelectedValueIndex;
    WizardForm.TypesCombo.OnChange(WizardForm.TypesCombo);

    if (UsagePage.SelectedValueIndex = 3) then
       Result := false
       else
        result:= true;

   end;
end;
 

Similar threads

后退
顶部