捕获其他安装程序文件的事件,如Inno Setup中的Notepad ++安装程序

时间:2015-06-18 09:08:47

标签: windows-installer installer inno-setup pascalscript

我想在Inno Setup中安装之前执行可执行文件(npp.exe)。但是我无法捕获npp.exe可执行文件的nextButton事件。有什么办法吗?我尝试使用以下代码:

function initializeSetup(): boolean;
var
  ResultCode: integer;
  path: string;
begin
   if Exec(('C:\Users\Paxcel\Downloads\npp.exe'), '', '', SW_SHOW,
       ewWaitUntilTerminated, ResultCode) then
    begin
       //result code = 0 for successful installation
       if (ResultCode = 0)then
          begin
              Result := True;
          end
          else
          begin
              Result := False;
          end;
    // handle success if necessary; ResultCode contains the exit code
     end
     else begin
        MsgBox(SysErrorMessage(ResultCode),mbError,MB_OK);
        Result := False;// handle failure if necessary; ResultCode contains the error code
     end;
   end;

在这段代码中,我想捕获Notepad ++设置的下一个按钮。 <{1}}等默认函数无法使用。

1 个答案:

答案 0 :(得分:2)

Notepad ++使用NSIS安装程序。

如果要以静默方式运行(任何)NSIS安装程序,请使用/S命令行开关。

请参阅NSIS Installer usage

顺便说一句,我认为路径C:\Users\Paxcel\Downloads仅用于测试。在真正的安装程序中,您必须将依赖项嵌入到安装程序中并将其解压缩到临时目录以执行它。

Inno Setup可以为您完成所有这些操作,您通常不需要使用Pascal Scripting自行编写代码。

[Run]
Source: "path\npp.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall

[Run]
Filename: "{tmp}\npp.exe"; Parameters: "/S"