如何用inno setup打包activex
需要解决三个问题,运行环境检测与安装,按顺序执行安装,activex注册。
运行环境检测与安装
最开始的方法,百度之后,根据网上的搜索的结果,使用了
RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A25302D-30C0-39D9-BD6F-21E6EC160475}', 'Version', version),最后的结果,我发现,跟我想的不一样,没有判断到是否已经安装了vc++9的环境,每次安装都会重复安装,最后,我发现,Uninstall中的GUID是不固定的,在不同的机器上面,安装之后,它会改变,原因不知。只好bings和google,
最后看了
http://blogs.msdn.com/b/astebner/archive/2010/10/20/10078468.aspx里面的How to detect the install state for the Visual C++ 2010 redistributable packages等文章,决定使用作者的办法。那就是调用msi.dll里面MsiQueryProductState函数。
我又在在传入值上面,又思考了半天,因为我用了作者提供的GUID号,返回值均为-2,而我的确已经安装了此产品了,我想可能是因为作者提供的产品GUID都与我手头上打包的x86.exe或者是x64.exe里面的产品GUID不一样,怎么看到这两个产品的GUID了,本人笨的很,只好装了一个wix的打包工具,解压缩这两个exe,然后,再看它们的wix格式的文件,最后在第一行看到了产品的GUID,跟作者提供的不一样,跟网上的那个GUID号也不一样。
静默安装
我在上面的文章里面看到了参数,不会用,最后查看了Exec的使用方法,才明白了,应该怎么写。
按顺序执行安装
开始写的是Files里面,自动注册activex,但结果经常会,运行环境还没有安装,就注册activex了,往往注册不成。
改为不让dll自动注册了,在安装完成之前,使用
RegisterServer(Is64BitInstallMode, ExpandConstant('{app}\SISSWebUKey.dll'), False);来进行注册。
整个安装打包文件如下
#define MyAppName "安全登录 for IE (64)"
#define MyAppVersion "2.0.0.1"
#define MyAppPublisher "公司名"
#define MyAppURL "www.demo.com"
#define MyAppExeName "test.dll"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{CBA6F794-BD25-45A2-9A91-8F11C3A2E3BA}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=D:\work2013\projectInstallFile
OutputBaseFilename=SISSUKeySetup64
Compression=lzma
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64
PrivilegesRequired=admin
[code]
#IFDEF UNICODE
#DEFINE AW "W"
#ELSE
#DEFINE AW "A"
#ENDIF
function MsiQueryProductState(ProductCode: string): integer;
external 'MsiQueryProductState{#AW}@msi.dll stdcall';
function MsiConfigureProduct(ProductCode: string;
iInstallLevel: integer; eInstallState: integer): integer;
external 'MsiConfigureProduct{#AW}@msi.dll stdcall';
var
HasRun:HWND;
var vc9SP1Missing: Boolean;
function InitializeSetup: Boolean;
var Path:string ;
ResultCode: Integer;
var
IniFile, OldString, NewString: string;
IniFileLines: TArrayOfString;
i: Integer;
currentIndex: Boolean;
var version: Cardinal;
begin
Result := true;
HasRun := FindWindowByClassName('IEFrame');
while HasRun<>0 do
begin
if MsgBox('安装程序检测到IE浏览器正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
begin
Result := false;
HasRun := 0;
end
else
begin
Result := true;
HasRun := FindWindowByClassName('IEFrame');
end;
end;
//这里的GUID号需要自己查看下载的vcredist_x64.exe是否是此GUID
if MsiQueryProductState('{DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}') <> 5 then begin
vc9SP1Missing := true;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
pt,IniFile, OldString, NewString: string;
IniFileLines: TArrayOfString;
ResultCode,i: Integer;
currentIndex: Boolean;
begin
if (CurStep=ssPostInstall) then
begin
if(vc9SP1Missing=true) then
begin
pt:= ExpandConstant('{tmp}\vcredist_x64.exe');//需要考虑返回值 0 ,是安装成功不需要重启 3010安装成功需要重启电脑 其它的是安装失败
if( not Exec(pt,'/passive /norestart"','',SW_HIDE,ewWaitUntilTerminated,ResultCode)) then
begin
MsgBox('C++运行环境安装失败,请手动安装!没有此控件,安全控件无法安装成功!', mbInformation, MB_OK);
end;
end;
end;
if(CurStep=ssDone) then
begin
RegisterServer(Is64BitInstallMode, ExpandConstant('{app}\test.dll'), False);
end;
end;
function NeedInstallVC9SP1(): Boolean;
begin
Result := vc9SP1Missing;
end;
function InitializeUninstall(): Boolean;
var
HasRun : Integer;
begin
Result := true;
HasRun := FindWindowByClassName('IEFrame');
while HasRun<>0 do
begin
if MsgBox('安装程序检测到IE浏览器正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
begin
Result := false;
HasRun := 0;
end
else
begin
Result := true;
HasRun := FindWindowByClassName('IEFrame');
end;
end;
end;
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "D:\work2013\projectOldKey64\NeedLib\vcredist_x64.exe"; DestDir: "{tmp}"; Check: NeedInstallVC9SP1
Source: "D:\work2013\projectOldKey64\SISSWebUKey\SISSWebUKey\Release\test.dll"; DestDir: "{app}"; Flags: promptifolder restartreplace
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[UninstallRun]
Filename: "regsvr32"; Parameters:"{app}\test.dll /u /s "
[UninstallDelete]
Type: files; Name:"{app}\test.dll"
如何用inno setup打包activex的更多相关文章
- Inno Setup 打包工具总结
Inno Setup 打包工具总结 分类: Install Setup 2013-02-02 15:44 2386人阅读 评论(0) 收藏 举报 最近打包用到了Inno setup,在这个过程中容易犯 ...
- 使用Inno Setup 打包.NET程序,并自动安装.Net Framework
使用Inno Setup 打包.NET程序,并自动安装.Net Framework http://www.cnblogs.com/xiaogangqq123/archive/2012/03/19/24 ...
- (Inno setup打包)检测系统是否已安装程序,若已安装则弹出卸载提示的代码
原文 http://bbs.itiankong.com/thread-30983-1-5.html 有6天没研究pascal代码了,昨天晚上突然来了灵感,终于解决了苦思冥想好几天没能解决的问题, 因此 ...
- Inno Setup打包的程序提升为管理员权限
Inno Setup打包的程序在Win7 64位系统上安装,安装步骤最后一步若选中运行程序,会跳出一个错误提示框. 这是因为64位win7系统运行程序时需要管理员权限,而打包的文件并没有这个权限就试图 ...
- Inno Setup打包添加和去除管理员权限
原文:Inno Setup打包添加和去除管理员权限 添加管理员权限 1.在[Setup]节点添加 PrivilegesRequired=admin 2.进入安装目录,找到文件SetupLdr.e32, ...
- inno setup 打包exe程序
inno setup 用于打包生成安装程序, 是通过的一个脚本 可以将 exe 执行文件以安装的形式,解压,添加依赖,创建快捷方式. 例如,我们写了个winform,我们怎么通过安装的形式,给客户的机 ...
- Inno Setup 打包的文件以管理员权限执行
最近发现一个问题,就是Inno Setup打包的程序安装完毕后执行需求管理员权限的程序的时候会失败( inno createprocess 须要提升),解决问题的最简单办法就是打包的后的程序也以管 ...
- 【程序打包工具 Inno Setup】CreateProcess 失败:代码 740(Inno Setup打包的程序提升为管理员权限)
原文参考 https://www.cnblogs.com/SnailProgramer/p/4243666.html http://blog.csdn.net/x356982611/article/d ...
- Inno Setup CreateProcess 失败:代码 740(Inno Setup打包的程序提升为管理员权限)
原文参考 https://www.cnblogs.com/SnailProgramer/p/4243666.html http://blog.csdn.net/x356982611/article/d ...
随机推荐
- MySql 杂记
1:声明一个int变量时,设置它默认为0,而不是空或null. int 型,取值范围-2,147,483,648 到 2,147,483,647 ,默认值是 0 int是值类型,读内存区间中指定长度单 ...
- MySQL数据库命名及设计规范
1.设计原则 1) 标准化和规范化 数据的标准化有助于消除数据库中的数据冗余.标准化有好几种形式,但 Third Normal Form(3NF)通常被认为在性能.扩展性和数据完整性方面达到了最好平衡 ...
- HQL常用的查询语句
摘录自某人,比较有用,比较全. // HQL: Hibernate Query Language. // 特点: // >> 1,与SQL相似,SQL中的语法基本上都可以直接使用. // ...
- shell--4.echo和printf
1. echo (1) echo ,显示普通字符串 echo "HelloWorld" 打印:HelloWorld (2) \ ,显示转义字符串 echo "\" ...
- 深入理解使用ListView时ArrayAdapter、SimpleAdapter、BaseAdapter的原理
在使用ListView的时候,我们传给setAdapter方法的Adapter通常是ArrayAdapter.SimpleAdapter.BaseAdapter,但是这几个Adapter内部究竟是什么 ...
- 2016 GitHub章鱼猫观察报告之开源统计
导读 GitHub 又发布了一年一度的章鱼猫观察报告.在这个报告中,分别对开源和社区做了一些有趣的统计,现将其中一些有趣的数据和趋势撷取出来分享给大家.完整的报告请移步Github. GitHub 上 ...
- iOS上架ipa上传问题那些事
iOS上架ipa上传问题那些事 原文: http://www.jianshu.com/p/1e22543285c2 字数513 阅读312 评论0 喜欢1 通过xcode直接打包上传,不会提示你的ip ...
- yii2事务运用举例
直接上代码: $db = Yii::$app->db; $transaction = $db->beginTransaction(); //开启事务 try { // 更新member表 ...
- String字符串去掉最后一个","号的几种方式
String a = "struts-default.xml,struts-plugin.xml,struts.xml"; String[] bStrings = a.split( ...
- 如何使用videojs兼容IE8浏览器
需要在服务器下运行 首先我们需要下载videojs包 https://github.com/videojs/video.js/releases 这里简单写了一个小栗子 <!DOCTYPE htm ...