簡體   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