2015-11-30 47 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位注册表。

相关问题