根据复选框答案有条件地添加注册表项 [英] Conditionally add registry key based on checkbox answer

查看:85
本文介绍了根据复选框答案有条件地添加注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Windows .NET应用程序使用Inno安装程序.我问用户是否要使用以下代码在Windows上启动应用程序:

I'm using Inno Setup for my Windows .NET app. I'm asking the user if they want to start the app with Windows with the following code:

[Tasks]
Name: "TaskEntry"; Description: "Start with Windows?"; GroupDescription: "Startup";

[code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = wpSelectTasks then                                          
  begin
    if WizardForm.TasksList.Checked[3] then
      MsgBox('Startup has been checked.', mbInformation, MB_OK)
    else
      MsgBox('Startup has not been checked.', mbInformation, MB_OK);
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
    WizardForm.TasksList.Checked[3] := False;
end;

如何添加注册表项而不是消息框?

How do I add the registry key instead of the message box?

我知道我可以无条件地做到这一点:

I'm aware that I can do it unconditionally with:

[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; \
    ValueName: "key"; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletevalue

推荐答案

您不需要任何代码.将 Tasks 参数添加到您的注册表项中仅在用户选择此任务时处理:

You don't need any code for this. Add a Tasks parameter to your registry entry and it will be processed only if this task is selected by the user:

[Registry]
Root: HKCU; Subkey: "Software\  [...] Flags: uninsdeletevalue; Tasks: TaskEntry

这篇关于根据复选框答案有条件地添加注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆