Conditionally add registry key based on checkbox answer

喜欢而已 提交于 2020-03-20 06:36:31

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/10825239/conditionally-add-registry-key-based-on-checkbox-answer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!