2

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

[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;

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

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

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

1 回答 1

4

您不需要任何代码。向您的注册表项添加一个Tasks参数,并且仅当用户选择此任务时才会处理该参数:

[Registry]
Root: HKCU; Subkey: "Software\  [...] Flags: uninsdeletevalue; Tasks: TaskEntry
于 2012-05-30T23:09:40.907 回答