加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

inno-setup – 使用innosetup中的函数添加注册表项

发布时间:2020-12-15 09:20:35 所属栏目:大数据 来源:网络整理
导读:如何使用函数中的值在innosetup中添加注册表项.我想设置 注册表中的IsServer值作为InstallAsServer的返回值 [Code][Registry]Root: HKLM; Subkey: "SoftwarecompanyproductSettings"; ValueType: string; ValueName: "IsServer"; ValueData: {code:Instal
如何使用函数中的值在innosetup中添加注册表项.我想设置
注册表中的IsServer值作为InstallAsServer的返回值

[Code]
[Registry]
Root: HKLM; Subkey: "SoftwarecompanyproductSettings"; ValueType: string; ValueName: "IsServer"; ValueData: {code:InstallAsServer}

var
  Page: TInputOptionWizardPage;
  IsServer: Boolean;
procedure InitializeWizard;
 begin
  Page := CreateInputOptionPage(wpWelcome,'Install Type','Select Install Type','Please select Installation type; If Server click Server else Client',True,False);

  // Add items
  Page.Add('Install as Server');
  Page.Add('Install as Client');

  // Set initial values (optional)
  Page.Values[0] := True;
  Page.Values[1] := False;
  IsServer := Page.Values[0];
end;

function InstallAsServer(emppararm: string): string; //emppararm not used just for syntax
begin
  if (IsServer=False) then
    begin
      result:= '0';
    end
  else
   begin
    result:= '1';
   end

end;

但即使我在页面中选择服务器或客户端,我总是将值设置为1

解决方法

这是因为您只在向导表单初始化时分配IsServer变量的值.您需要从InstallAsServer函数中理想地读取实际值,因此您甚至可以删除IsServer变量.您可以将代码简化为以下内容:

[Registry]
Root: HKLM; Subkey: "SoftwarecompanyproductSettings"; ValueType: string; ValueName: "IsServer"; ValueData: {code:InstallAsServer}

[Code]
var
  Page: TInputOptionWizardPage;

procedure InitializeWizard;
begin
  Page := CreateInputOptionPage(wpWelcome,False);

  // add items
  Page.Add('Install as Server');
  Page.Add('Install as Client');

  // set initial values (optional)
  Page.Values[0] := True;
  Page.Values[1] := False;
end;

function InstallAsServer(Value: string): string;
begin
  // read the actual value directly from the Page
  if not Page.Values[0] then
    Result := '0'
  else
    Result := '1';    
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读