Reputation: 113
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
Upvotes: 2
Views: 655
Reputation: 54812
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
Upvotes: 4