2015-11-30 45 views
1

我想在用戶接受密鑰添加後添加註冊表項。 關鍵會告訴Firefox哪裏可以找到我們的插件(存儲在應用程序文件夾中)Inno Setup中運行條目中運行腳本代碼(添加註冊表項)而不是可執行文件

用戶將得到一個複選框「install ff plug-in?」與我們問「安裝Chrome插件」「安裝即插件?

[Code] 
function GetHKLM: Integer; 
begin 
    if IsWin64 then 
    Result := HKLM64 
    else 
    Result := HKLM32; 
end; 

function CheckForMozilla: Boolean; 
begin 
    Result := False; 
    if RegKeyExists(GetHKLM(), 'SOFTWARE\Mozilla\Mozilla Firefox') then 
    begin 
    Result := True; 
    end; 

    if RegKeyExists(GetHKLM(), 'SOFTWARE\Mozilla\Firefox') then 
    begin 
    Result := True; 
    end; 
end; 

function AddFFKey : Boolean; 
begin 
    // Some way to write this key in code section : 
    GetHKLM()\SOFTWARE\Mozilla\Mozilla Firefox\extensions\[email protected]' 
end; 

[Run] 
Filename: AddFFKey; Flags: runascurrentuser postinstall ; \ 
    Check: CheckForMozilla; Description: "Install firefox plug-in" 

謝謝大家!
史蒂夫

回答

0

您可以通過實現NextButtonClick event function捕捉完成按鈕點擊更換一個腳本程序調用可執行調用。

#define InstallFFPluginDesc "Install firefox plug-in" 

[Run] 
FileName: "fake.exe"; Flags: postinstall; Description: "{#InstallFFPluginDesc}"; \ 
    Check: CheckForMozilla 

[Code] 

procedure AddFFKey; 
begin 
    Log('Adding FF key'); 
    RegWriteStringValue(GetHKLM(), 
    'SOFTWARE\Mozilla\Mozilla Firefox\extensions\[email protected]', 
    ...); 
end; 

function NextButtonClick(CurPageID: Integer): Boolean; 
var 
    Index: Integer; 
begin 
    if CurPageID = wpFinished then 
    begin 
    // When restart is needed, the RunList is never populated/shown. 
    if WizardForm.RunList.Items.Count > 0 then 
    begin 
     // Find the RunList entry for the FF plugin 
     Index := WizardForm.RunList.Items.IndexOf('{#InstallFFPluginDesc}'); 
     // Does it exist and is it checked? 
     if (Index >= 0) and WizardForm.RunList.Checked[Index] then 
     begin 
     // Uncheck, so that the fake.exe is not run 
     WizardForm.RunList.Checked[Index] := False; 
     // Do our scripted action instead 
     AddFFKey; 
     end; 
    end; 
    end; 
    Result := True; 
end; 

另一種方法是增加一個工作,但空操作[Run]項,並使用BeforeInstall or AfterInstall parameter打電話給你的腳本代碼。

這是一個更簡單,更強大的解決方案,只是帶有副作用(即使不需要執行任何操作,您也必須運行某個進程)。

[Run] 
FileName: "{cmd}"; Parameters: "/C echo noop"; Flags: postinstall runhidden; \ 
    Description: "Install firefox plug-in"; Check: CheckForMozilla; BeforeInstall: AddFFKey 

[Code] 

procedure AddFFKey; 
begin 
    Log('Adding FF key'); 
    ... 
end; 

我相信你的GetHKLM邏輯是錯誤的。 Firefox總是寫入32位註冊表。

相關問題