繁体   English   中英

Inno Setup,APP启动Windows启动时

[英]Inno Setup, APP start When windows start

对于Inno Setup,我想在Windows启动时为MyAPP Auto Start创建一个复选框Task。 我的代码如下:

并且,如何编写下面的代码 - DO_Set_AutoStart_WhenWindowsStart()^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Tasks]
Name: "StartMenuEntry" ; Description: "Start my app when Windows starts" ; GroupDescription: "Windows Startup"; MinVersion: 4,4;

[code]

//Do Additional Task - Auto Start when Windows Start 

function NextButtonClick(CurPageID: Integer): Boolean;
var
  Index: Integer;
begin
  Result := True;
  if CurPageID = wpSelectTasks then
  begin
    Index := WizardForm.TasksList.Items.IndexOf('Start my app when Windows starts');
    if Index <> -1 then
    begin
      if WizardForm.TasksList.Checked[Index] then
        MsgBox('First task has been checked.', mbInformation, MB_OK)
        DO_Set_AutoStart_WhenWindowsStart();
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      else
        MsgBox('First task has NOT been checked.', mbInformation, MB_OK);
    end;
  end;
end;

您无需使用[code]部分添加自动启动应用程序。

例如,有不同的方法可以实现这一目标

[icons]
Name: "{userstartup}\My Program"; Filename: "{app}\MyProg.exe"; Tasks:StartMenuEntry;
Name: "{commonstartup}\My Program"; Filename: "{app}\MyProg.exe"; Tasks:StartMenuEntry;

{userstartup}和{commonstartup}之间的区别(如果不是很明显)是{userstartup}影响当前用户的启动菜单条目,{commonstartup}影响目标机器的所有用户。


编辑

您还可以使用注册表来启动应用程序。 我添加这个是因为在评论中提到的OP所描述的方法在Windows 8上不起作用(因为缺少开始菜单,我忘了)。 我手边没有Windows 8进行测试,所以由你来测试这是否适用于Windows 8。

自WinXP以来, 注册表中Run键存在,因此您可以配置窗口以从安装程序自动运行程序,添加如下内容:

[Registry]
;current user only
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MyProgram"; ValueData: "{app}\MyProg.exe"; Tasks:AutoRunRegistry;

;any user
Root: HKLM; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MyProgram"; ValueData: "{app}\MyProg.exe"; Tasks:AutoRunRegistry;

不要错过我也将示例中的Tasks参数更改为AutoRunRegistry

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM