如何用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 ...
随机推荐
- thinkphp自定义标签库
thinkphp ~ php中 的类, 的成员变量, 本身是没有类型说明的, 那么我怎么知道它的类型呢? 或初始值呢? 通常在类定义中, 如果能给一个初始值的(对于已知简单类型的),最好给一个初始值, ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 前端工具之Gulp
Gulp是一款前端自动化的工具,如果能熟练使用Gulp来进行开发一定可以节省很多的时间,也可以快速的提高工作效率. 在使用Gulp之前就是要配置好Gulp安装的环境,这是我们能使用Gulp快速开发的第 ...
- python 3编码
python 3和2很大区别就是python本身改为默认用unicode编码. 字符串不再区分"abc"和u"abc", 字符串"abc"默 ...
- PHP合并2个数字键数组的值
先要了解一个基础知识点:PHP数组合并+与array_merge的区别分析 & 对多个数组合并去重技巧 <?php /** * PHP合并2个数字键数组的值 * * @param arr ...
- PHP mysql与mysqli事务详解
官方对PHP连接到MySQL数据库服务器的三种主要的API简介如下: http://php.net/manual/zh/mysqli.overview.php PHP mysql与mysqli事务详解 ...
- 记录一下git 的常用命令
以后如果要写一个东西,最好先搭建一个本地仓库,用版本控制对其进行操作,可能一开始有一些麻烦,但是很有可能会受益无穷. 说到git,必然会和github联系起来. 不管是在ubuntu里面还是在Wind ...
- java27
1:反射(理解) (1)类的加载及类加载器 (2)反射: 通过字节码文件对象,去使用成员变量,构造方法,成员方法 (3)反射的使用 A:通过反射获取构造方 ...
- ABAP 订单转交货单
*& Report ZSDR025 *& *&---------------------------------------------------------------- ...
- int main( int argc, char **argv)
1.参数 (有时参数是void) argc是程序运行时参数个数 argv是存储参数的数组,可以用char* argv[],也可以用char **argv. 例如编译一个hello.c的程序 1 #in ...