从此为 NSIS 开发的插件也通用于 INNO 了。
callnsis.dll 就是新作出来的调用 NSIS 插件地通用调用插件,适用于任何程序的正常调用,当然就会包括 INNO 了。
这个 callnsis.dll 的调用函数是 callplug 。Delphi 中声明如下。
procedure callplug(parentwnd: Integer; pluginname, funcname, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10: PChar); stdcall;
external callnsis.dll name callplug;
预留 10 个参数,参数根据 NSIS 例子中来填入。10 个一般够用了,如果没用的就填空字符串。
看看以下的 INNO 例子。跟 NSIS 一样的效果。
渐显渐隐的闪屏效果,还附带背景声音。
以下是引用片段: ; -- Example1.iss -- ; 演示如何调用 NSIS 插件的 INNO 安装程序。 [Setup] AppName=我的程序 AppVerName=我的程序 版本 1.5 DefaultDirName={pf}\我的程序 DefaultGroupName=我的程序 UninstallDisplayIcon={app}\MyProg.exe [Files] Source: "MyProg.exe"; DestDir: "{app}" Source: "MyProg.hlp"; DestDir: "{app}" Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme Source: "callnsis.dll"; DestDir: "{tmp}"; Flags: dontcopy Source: "AdvSplash.dll"; DestDir: "{tmp}"; Flags: dontcopy Source: "logo.bmp"; DestDir: "{tmp}"; Flags: dontcopy Source: "logo.wav"; DestDir: "{tmp}"; Flags: dontcopy [Icons] Name: "{group}\我的程序"; Filename: "{app}\MyProg.exe" [code] procedure callplug(parentwnd: Integer; pluginname,funcname,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10: PChar); external ’callplug@files:callnsis.dll stdcall’; procedure InitializeWizard(); begin ExtractTemporaryFile(ExtractFileName(ExpandConstant(’{tmp}\AdvSplash.dll’))); ExtractTemporaryFile(ExtractFileName(ExpandConstant(’{tmp}\logo.bmp’))); ExtractTemporaryFile(ExtractFileName(ExpandConstant(’{tmp}\logo.wav’))); callplug(0,ExpandConstant(’{tmp}\AdvSplash.dll’),’show’,’2800’,’1400’,’1200’,’-1’,ExpandConstant(’{tmp}\logo’),’’,’’,’’,’’,’’); end; |
以下附件包括所有插件(包括通用调用插件 callnsis.dll 和 NSIS 专用插件 AdvSplash.dll)。
testapp.rar
delphi 调用例子。
以下是引用片段: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; procedure callplug(parentwnd: Integer; pluginname,funcname, param1,param2,param3,param4,param5,param6,param7,param8,param9,param10: PChar); stdcall; external ’callnsis.dll’ name ’callplug’; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); begin callplug(0,’AdvSplash.dll’,’show’,’2800’,’1400’,’1200’,’-1’,’logo’,’’,’’,’’,’’,’’); end; end. |
附带例子程序。
稍稍修改了一下插件,加多了返回值,因为有时候需要返回结果。
以下是引用片段: ; -- Example1.iss -- ; 演示如何调用 NSIS 插件的 INNO 安装程序。 ; 带有返回值的调用插件 [Setup] AppName=我的程序 AppVerName=我的程序 版本 1.5 DefaultDirName={pf}\我的程序 DefaultGroupName=我的程序 UninstallDisplayIcon={app}\MyProg.exe [Files] Source: "MyProg.exe"; DestDir: "{app}" Source: "MyProg.hlp"; DestDir: "{app}" Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme Source: "callnsis.dll"; DestDir: "{tmp}"; Flags: dontcopy Source: "AdvSplash.dll"; DestDir: "{tmp}"; Flags: dontcopy Source: "logo.bmp"; DestDir: "{tmp}"; Flags: dontcopy Source: "logo.wav"; DestDir: "{tmp}"; Flags: dontcopy [Icons] Name: "{group}\我的程序"; Filename: "{app}\MyProg.exe" [code] function callplug(parentwnd: Integer; pluginname,funcname,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10: PChar): Integer; external ’callplug@files:callnsis.dll stdcall’; procedure InitializeWizard(); var val: Integer; begin ExtractTemporaryFile(ExtractFileName(ExpandConstant(’{tmp}\AdvSplash.dll’))); ExtractTemporaryFile(ExtractFileName(ExpandConstant(’{tmp}\logo.bmp’))); ExtractTemporaryFile(ExtractFileName(ExpandConstant(’{tmp}\logo.wav’))); val:=callplug(0,ExpandConstant(’{tmp}\AdvSplash.dll’),’show’,’2800’,’1400’,’1200’,’-1’,ExpandConstant(’{tmp}\logo’),’’,’’,’’,’’,’’); // 在 NSIS 的例子中调用是如下的: // SetOutPath $TEMP # 设置输出位置为临时目录 // File /oname=logo.bmp "my_logo.bmp" # 释放文件 // File /oname=logo.wav "my_logo.wav" # 释放文件 // advsplash::show 2800 1400 1200 -1 $TEMP\logo # 调用插件 // Pop $0 # 取返回值: 返回 ’1’ 表示用户提前关闭闪屏, 返回 ’0’ 表示闪屏正常结束, 返回 ’-1’ 表示闪屏显示出错 // 基本上,调用的方法都是一样的,所以只要稍稍看看 NSIS 的插件例子,你就可以在 INNO 中利用以上方法进行调用 if val = 1 then MsgBox(’你点击了闪屏窗口,导致闪屏提前关闭!’, mbConfirmation, MB_OK); end; |
INNO 脚本附件:
testapp2.rar
以下是引用片段: (夜凉如水 @ 2005年09月12日 11时52分) 我想把被调用的文件放到其他的目录里面, 不知道该怎么设置.还有如果这个安装程序做好了以后,到其他的机器上没有了被调用的文件 是否会出错 |

插件文件已经被打包。安装程序可以独立运行。
没必要放到其他目录,安装程序自动释放插件到临时目录,然后调用,安装结束后自动删除。这样不好吗?
莫名汉化的 INNO Setup,附带完整的中文帮助。
http://www.hanzify.org/index.php?Go=Show::List&ID=7392
INNO Setup 论坛问题精华。
http://bbs.hanzify.org/read.php?tid=24278
发现有些代码写得多余了,改一下
以下是引用片段: Source: "callnsis.dll"; Flags: dontcopy Source: "AdvSplash.dll"; Flags: dontcopy Source: "logo.bmp"; Flags: dontcopy Source: "logo.wav"; Flags: dontcopy |
上面的目标目录“DestDir: "{app}"; ”可以不写,因为该文件标志为“dontcopy”。
下面的以前的那个代码经过运算后,还是得到文件名,所以多余了,应该简略为以下代码。
以下是引用片段: procedure InitializeWizard(); begin ExtractTemporaryFile(’AdvSplash.dll’); ExtractTemporaryFile(’logo.bmp’); ExtractTemporaryFile(’logo.wav’); callplug(0,ExpandConstant(’{tmp}\AdvSplash.dll’),’show’,’2800’,’1400’,’1200’,’-1’,ExpandConstant(’{tmp}\logo’),’’,’’,’’,’’,’’); end; |