从此为 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. |
附带例子程序。
delphiapp.rar
稍稍修改了一下插件,加多了返回值,因为有时候需要返回结果。
以下是引用片段: ; -- 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
|